Skip to Content
0

PO Text Material Master MM03

May 30, 2017 at 05:32 PM

142

avatar image

I am trying to figure out how I can get the PO Text from the material master and to have it output to a report. I created a SQ01 report but it can only show one line. This is what I have so far and it's not working. Can someone help me with the program? Thanks.

TABLES: MARA.
"PBIM,


SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

DATA: BEGIN OF HTEXT.
INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.

DATA: BEGIN OF LTEXT OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.

DATA: BEGIN OF DTEXT OCCURS 50.
DATA: MATNR LIKE PBIM-MATNR.
INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.

DATA: TNAME LIKE THEAD-TDNAME.

SELECT * FROM MARA WHERE MATNR IN S_MATNR.

CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = 'BEST'
LANGUAGE = 'E'
NAME = lv_name
OBJECT = 'MATERIAL'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
* OLD_LINE_COUNTER =
TABLES
LINES = LT_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.
* Implement suitable error handling here
ENDIF.

LOOP AT LTEXT.
IF LTEXT-TDLINE NE ''.
MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
MOVE MARA-MATNR TO DTEXT-MATNR.
APPEND DTEXT.
ENDIF.
ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
satyapriyanka vana May 31, 2017 at 02:09 AM
1

Hi,

Check this code. Might be helpful.

TABLES : mara.
SELECT-OPTIONS : s_matnr FOR mara-matnr.
TYPES : BEGIN OF ty_out,
matnr TYPE mara-matnr,
tdline TYPE tline-tdline,
END OF ty_out.
TYPES : BEGIN OF ty_matnr,
matnr TYPE mara-matnr,
END OF ty_matnr.
DATA : it_matnr TYPE TABLE OF ty_matnr,
it_lines TYPE TABLE OF tline,
it_out TYPE STANDARD TABLE OF ty_out,
wa_out LIKE LINE OF it_out,
v_name TYPE thead-tdname.

FIELD-SYMBOLS : <fs_matnr> LIKE LINE OF it_matnr,
<fs_lines> LIKE LINE OF it_lines.

START-OF-SELECTION.
SELECT matnr FROM mara INTO TABLE it_matnr WHERE matnr IN s_matnr.
IF NOT it_matnr IS INITIAL.
LOOP AT it_matnr ASSIGNING <fs_matnr>.
REFRESH : it_lines. CLEAR v_name.
v_name = <fs_matnr>-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'BEST'
language = 'E'
name = v_name
object = 'MATERIAL'
TABLES
lines = it_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.
DELETE it_lines WHERE tdline IS INITIAL.
LOOP AT it_lines ASSIGNING <fs_lines>.
wa_out-matnr = <fs_matnr>-matnr.
wa_out-tdline = <fs_lines>-tdline.
APPEND wa_out TO it_out.
CLEAR wa_out.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
IF NOT it_out IS INITIAL.
LOOP AT it_out INTO wa_out.
WRITE :/1(15) wa_out-matnr, 16 wa_out-tdline.
ENDLOOP.
ENDIF.

Regards,

Priyanka.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks. This is what I got.

This what I am trying to accomplish. Your code was very helpful Thanks.

0

Hi Shawn,

It is good to know that my answer is helpful to you. If your question was answered, please mark the answer as the correct answer and close the thread.

Thanks,

Priyanka.

0