on 07-11-2011 12:01 PM
Hello Experts,
I have used the standard MEDRUCK and copied to ZMEDRUCK. I want the PO header text to print in my form.
I have used subroutine-pool and called it in the form.
Here is my subroutine
FORM fetch_table_data TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
TABLES EKKO.
DATA: BEGIN OF header OCCURS 0,
ld_txt1(163),
ld_txt2(163),
ld_txt3(163),
END OF header.
DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
ID like THEAD-TDID,
TNAME LIKE THEAD-TDNAME,
TDOBJECT like THEAD-TDOBJECT.
DATA HTEXT LIKE EKKO-EBELN.
* HTEXT = EKKO-EBELN.
READ TABLE in_tab WITH KEY EKKO-EBELN.
if sy-subrc = 0.
TNAME = in_tab-value.
ENDIF.
TNAME = EKKO-EBELN.
*CONCATENATE EKPO-ebeln EKPO-ebelp INTO v_item_text.
*MOVE v_head_text to HNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = 'F01'
language = 'E'
name = TNAME
object = 'EKKO'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER = TNAME
tables
lines = li_lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
* WRONG_ACCESS_TO_ARCHIVE = 7
* OTHERS = 8
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR out_tab.
out_tab-VALUE = TNAME.
CONDENSE out_tab-VALUE.
MODIFY out_tab TRANSPORTING VALUE WHERE NAME = 'TNAME'.
ENDFORM.
And my script in the form is
PERFORM FETCH_TABLE_DATA IN PROGRAM ZMEDRUCK_SUBP2
USING &EKKO-EBELN&
CHANGING &TNAME&
ENDPERFORMpar RECEIVED FROM M/S &TNAME&
The header text is still not flowing in my form.
What mistake i'm I doing here ?
How can I resolve this ?
Pls help !
Hi,
Data is li_lines internal table. 1st you have to read the text form the internal table line by sy-tabix.
At last you have to concatenate these variable into the out tab value.
you can use the following code
ORM fetch_table_data TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
TABLES EKKO.
DATA: BEGIN OF header OCCURS 0,
ld_txt1(163),
ld_txt2(163),
ld_txt3(163),
END OF header.
DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
ID like THEAD-TDID,
TNAME LIKE THEAD-TDNAME,
TDOBJECT like THEAD-TDOBJECT.
DATA HTEXT LIKE EKKO-EBELN.
READ TABLE in_tab WITH KEY EKKO-EBELN.
if sy-subrc = 0.
TNAME = in_tab-value.
ENDIF.
ALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
id = 'F01'
language = 'E'
name = TNAME
object = 'EKKO'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
tables
lines = li_lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data : f_lines TYPE i,
DESCRIBE TABLE li_lines LINES f_lines.
data: lstr type String,
lstr1 type string,
lstr2 type string,
lstr3 type string,
lstr4 type string.
read table li_lines index 1.
lstr = li_lines
condense lstr.
clear li_lines
read table li_lines index 2.
lstr1 = li_lines
condense lstr.
clear li_lines
read table li_lines index 3.
lstr2 = li_lines
condense lstr.
clear li_lines
if f_lines GT 3.
ead table li_lines index 4.
lstr3 = li_lines
condense lstr.
clear li_lines
ead table li_lines index 5.
lstr4 = li_lines
condense lstr.
clear li_lines
endif.
data : v_text type text.
concatenate lstr1 lstr2 lstr3 lstr4 into v_text separate by ' '.
CLEAR out_tab.
READ TABLE out_tab WITH KEY name = 'TNAME'.
out_tab-value = v_text
MODIFY out_tab INDEX sy-tabix.
Regards
Nayan Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have used the same code. But still the data is not flowing.
Here is my code.
Please check and revert.
PROGRAM ZMEDRUCK_SUBP2.
FORM fetch_table_data TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
TABLES EKKO.
DATA: BEGIN OF header OCCURS 0,
ld_txt1(163),
ld_txt2(163),
ld_txt3(163),
END OF header.
DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
ID like THEAD-TDID,
TNAME LIKE THEAD-TDNAME,
TDOBJECT like THEAD-TDOBJECT.
DATA HTEXT LIKE EKKO-EBELN.
DATA f_lines TYPE P.
* HTEXT = EKKO-EBELN.
READ TABLE in_tab WITH KEY EKKO-EBELN.
if sy-subrc = 0.
TNAME = in_tab-value.
ENDIF.
*TNAME = EKKO-EBELN.
*CONCATENATE EKPO-ebeln EKPO-ebelp INTO v_item_text.
*MOVE v_head_text to HNAME.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = TNAME
IMPORTING
OUTPUT = TNAME
.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = 'F01'
language = 'E'
name = TNAME
object = 'EKKO'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER = TNAME
tables
lines = li_lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
* WRONG_ACCESS_TO_ARCHIVE = 7
* OTHERS = 8
.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE li_lines INDEX 1.
IF sy-subrc = 0.
header-ld_txt1 = li_lines-tdline.
ENDIF.
DESCRIBE TABLE li_lines LINES f_lines.
data: lstr type String,
lstr1 type string,
lstr2 type string,
lstr3 type string,
lstr4 type string.
read table li_lines index 1.
lstr = li_lines.
condense lstr.
clear li_lines.
read table li_lines index 2.
lstr1 = li_lines.
condense lstr.
clear li_lines.
read table li_lines index 3.
lstr2 = li_lines.
condense lstr.
clear li_lines.
if f_lines GT 3.
read table li_lines index 4.
lstr3 = li_lines.
condense lstr.
clear li_lines.
read table li_lines index 5.
lstr4 = li_lines.
condense lstr.
clear li_lines.
endif.
DATA: v_text type text.
CONCATENATE lstr1 lstr2 lstr3 lstr4 into v_text separated by ' '.
CLEAR out_tab.
READ TABLE out_tab WITH KEY name = 'TNAME'.
out_tab-value = v_text.
MODIFY out_tab INDEX sy-tabix.
ENDFORM.
And my script is :
/:PERFORM FETCH_TABLE_DATA IN PROGRAM ZMEDRUCK_SUBP2
/:USING &EKKO-EBELN&
/:CHANGING &TNAME&
/: ENDPERFORM
IL RECEIVED FROM M/S &TNAME&
Ya I have defined it as,
/: DEFINE &TNAME& = ' '
The problem with debugging is , im working on a client where there is no test data available. To check I have write a code in one client and transport it to another client to check. Hence im feeling it a lot more difficult to manage. Can u pls go through the code and check whether Its correct and how can I manage in this situation.
Thanks in advance.
dear expert,
we have created salary slip in smartforms, earlier its setting according to portarit form and due to user requirement we have changed the setting in landscape forms.we are getting the values,but alligment of valus are distorted. please suggest wa to come this issue.
Regards
Pranav Baghel
Sap-Abap
Hi SAP_WIZ,
I debugged the code completely.
The input parameter passed to FM i.e,. TNAME contains 'XXXXXXXXXX' after the read table before passed to FM. If I manually delete that 'XXXXXXXXXX' and give the actual EKKO-EBELN value for ex: '0000001055' its printing the correct value. If I pass the same 'XXXXXXXXXXX' then field is blank.
PLS HELP !
Hi,
Then your problem is:
1)The script isnt passing value to your form for EBELN.
2)EKKO-EBELN isnot populated in teh subroutine pool.
3)You need to just read it_input , to pass EBELN to read_text.
dont repeat tNAME= EKKO-EBELN after that , it doesnt make sense,because that overwrites your value.
4)Debug your script and check if any value is coming in EKKO-EBELN in the script?
EKKO-EBELN wont be populated in the subroutine pool ,as its being called from script.
Thank you so much for your reply.
EKKO-EBELN wont be populated in the subroutine pool ,as its being called from script.
As u have mentioned script is not passing values to the subroutine. I have debugged the program, script is passing only XXXXXXXXXX.
Can u pls explain me the third point briefly.
3)You need to just read it_input , to pass EBELN to read_text.
dont repeat tNAME= EKKO-EBELN after that , it doesnt make sense,because that overwrites your value.
Thanks in advance.
READ TABLE in_tab WITH KEY EKKO-EBELN.
if sy-subrc = 0.
TNAME = in_tab-value.
ENDIF.
*ekko-ebeln isnt populated, so your read statement will always fail.
TNAME = EKKO-EBELN. "remove this.
*you are overwriting the value of TNAME, which you populated through read statement.Then what was the point of assigning it from read statement in teh first place.
just do a read oin in_tab index1.pass the value to tname.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.