Question:
Dear Gurus,
I am trying to write out all my long text on a single line but my output just gives the first line.
Please can someone help.
REPORT zep NO STANDARD PAGE HEADING
LINE-SIZE 1000
LINE-COUNT 59
MESSAGE-ID zz.
*** Data definitions
TABLES : marc. "Material Master: C Segment
TYPES: BEGIN OF str1,
matnr TYPE matnr, "Material Number
werks TYPE werks_d, "plant
dispo TYPE dispo, "MRP controller
text(72) TYPE c, "Long text
END OF str1.
DATA:ws_name(24) TYPE c,
ws_line(1000) TYPE c.
DATA: itab1 TYPE STANDARD TABLE OF str1 WITH HEADER LINE,
text_head TYPE STANDARD TABLE OF thead WITH HEADER LINE,
text_line TYPE STANDARD TABLE OF tline WITH HEADER LINE.
* Fields for Temp Storage
DATA: v_id TYPE tdid,
v_language TYPE spras,
v_name TYPE tdobname,
v_object TYPE tdobject.
*** Selection screen
SELECT-OPTIONS: s_matnr FOR marc-matnr,
s_werks FOR marc-werks,
s_dispo FOR marc-dispo.
*** Start of processing
START-OF-SELECTION.
SELECT matnr werks dispo FROM marc INTO TABLE itab1
WHERE matnr IN s_matnr
AND werks IN s_werks.
*write data
WRITE : 'Material no.',
14 'Plant.',
22 'MRP.',
28 'Long Text.'.
ULINE.
LOOP AT itab1.
* CLEAR text_line.
CONCATENATE itab1-matnr itab1-werks INTO ws_name SEPARATED BY space.
* Get Purchasing text
v_id = 'LTXT'.
v_language = sy-langu.
v_name = ws_name.
v_object = 'MDTXT'.
REFRESH text_line.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = v_id
language = v_language
name = v_name
object = v_object
IMPORTING
header = text_head
TABLES
lines = text_line
EXCEPTIONS
id = 4
language = 8
name = 12
not_found = 20
object = 16
reference_check = 24.
LOOP AT text_line.
IF NOT text_line-tdline(72) IS INITIAL.
CONCATENATE ws_line(1000) text_line-tdline(72) INTO
ws_line SEPARATED BY space.
ON CHANGE OF itab1-matnr OR itab1-werks.
WRITE: / itab1-matnr,
14 itab1-werks,
22 itab1-dispo,
28 ws_line.
* CLEAR ws_line.
ENDON.
ENDIF.
ENDLOOP.
ENDLOOP.
_________________
Many thanks,
Helen.
Answer:
is it data related REF: ON CHANGE do they change in the inner loop?
Answer:
is it data related REF: ON CHANGE do they change in the inner loop?
I say this because its coming out once
Debug it
Answer:
LOOP AT text_line.
IF NOT text_line-tdline(72) IS INITIAL.
CONCATENATE ws_line(1000) text_line-tdline(72) INTO
ws_line SEPARATED BY space.
ON CHANGE OF itab1-matnr OR itab1-werks.
WRITE: / itab1-matnr,
14 itab1-werks,
22 itab1-dispo,
28 ws_line.
* CLEAR ws_line.
ENDON.
ENDIF.
ENDLOOP.
Why are you using ON CHANGE?
TEXT_LINE contains only one MATERIAL-WERKS combination... you refresh it before execute 'READ_TEXT'...
So:
clear ws_line.
loop at TEXT_line.
concatenate if you like.
endloop.
write results....
Regards
Answer:
I thought that text line contained one line per line of text??,
The user wants the option of having the text displayed on one line or several lines (as per materail memo), thus I used ON CHANGE to try to write out all the text on one line.
However other ways of doing this would be gratefully recieved.
_________________
Many thanks,
Helen.
Answer:
Change section of code to:
clear ws_line.
WRITE: / itab1-matnr,
14 itab1-werks,
22 itab1-dispo.
LOOP AT text_line.
IF NOT text_line-tdline(72) IS INITIAL.
CONCATENATE ws_line(1000) text_line-tdline(72) INTO
ws_line SEPARATED BY space.
ENDIF.
ENDLOOP.
write 28 ws_line.
endloop.
_________________
Tuly Idiot (probationer)
Now available for work in the UK!
Answer:
Hi cheers but...
This writes out the total text, but also writes out a new line for all the lines of the text, and gives a line for all material numbers.
I am trying to get a single line of all of the text against each material number with text, but no entry unless the material/plant has got text.
_________________
Many thanks,
Helen.
Answer:
Add a check for empty text table before writing material.
Also there is no way that the code below writes a new line for each text line, there is no write in the lowest loop.
Debug your code, output can sometimes give misleading results that look like a different cause.
clear ws_line.
WRITE: / itab1-matnr,
14 itab1-werks,
22 itab1-dispo.
LOOP AT text_line.
IF NOT text_line-tdline(72) IS INITIAL.
CONCATENATE ws_line(1000) text_line-tdline(72) INTO
ws_line SEPARATED BY space.
ENDIF.
ENDLOOP.
write 28 ws_line.
endloop.
_________________
Tuly Idiot (probationer)
Now available for work in the UK!