Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Basic and Purchase Text

I have used read_text function module for reading line by line of the basic data. Here my requirement is in the output list which I need Basic text to be in a single line.

TABLES MARA.

TYPES BEGIN OF TY_TLINE.

INCLUDE STRUCTURE TLINE.

TYPES END OF TY_TLINE.

TYPES BEGIN OF TY_THEAD.

INCLUDE STRUCTURE THEAD.

TYPES END OF TY_THEAD.

TYPES: BEGIN OF TY_MARC,

MATNR TYPE MARC-MATNR,

WERKS TYPE MARC-WERKS,

END OF TY_MARC.

TYPES: BEGIN OF TY_OUTTAB.

TYPES: MATNR TYPE MATNR,

WERKS TYPE WERKS.

INCLUDE STRUCTURE TLINE.

TYPES: END OF TY_OUTTAB.

TYPES: BEGIN OF TY_PRINTTAB,

MATNR TYPE MATNR,

WERKS TYPE WERKS,

TD1LN TYPE TDLINE,

TD2LN TYPE TDLINE,

END OF TY_PRINTTAB.

DATA: THEAD TYPE TY_THEAD,

TLINE TYPE STANDARD TABLE OF TY_TLINE,

T_MARC TYPE STANDARD TABLE OF TY_MARC,

W_MARC TYPE TY_MARC.

DATA: WLINE TYPE TY_TLINE,

L_MATNR TYPE THEAD-TDNAME .

DATA: I_OUTTAB TYPE STANDARD TABLE OF TY_OUTTAB INITIAL SIZE 0,

K_OUTTAB TYPE STANDARD TABLE OF TY_OUTTAB INITIAL SIZE 0,

W1_OUTTAB TYPE TY_OUTTAB,

W2_OUTTAB TYPE TY_OUTTAB.

DATA: PRINTTAB TYPE STANDARD TABLE OF TY_PRINTTAB INITIAL SIZE 0,

W_PRINTTAB TYPE TY_PRINTTAB.

SELECT MATNR FROM MARA INTO W_MARC WHERE MATNR = 'MATERIAL0002' OR MATNR = 'MATERIAL0001'.

IF SY-SUBRC = 0.

MOVE W_MARC-MATNR TO L_MATNR.

ENDIF.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'GRUN'

LANGUAGE = SY-LANGU

NAME = L_MATNR

OBJECT = 'MATERIAL'

IMPORTING

HEADER = THEAD

TABLES

LINES = TLINE.

IF TLINE IS NOT INITIAL.

MOVE-CORRESPONDING W_MARC TO W1_OUTTAB.

LOOP AT TLINE INTO WLINE.

MOVE-CORRESPONDING WLINE TO W1_OUTTAB.

APPEND W1_OUTTAB TO I_OUTTAB.

ENDLOOP.

ELSE.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'BEST'

LANGUAGE = SY-LANGU

NAME = L_MATNR

OBJECT = 'MATERIAL'

IMPORTING

HEADER = THEAD

TABLES

LINES = TLINE.

MOVE-CORRESPONDING W_MARC TO W1_OUTTAB.

LOOP AT TLINE INTO WLINE.

MOVE-CORRESPONDING WLINE TO W1_OUTTAB.

APPEND W1_OUTTAB TO K_OUTTAB.

ENDLOOP.

ENDIF.

ENDSELECT.

LOOP AT I_OUTTAB INTO W1_OUTTAB.

READ TABLE K_OUTTAB WITH KEY MATNR = W1_OUTTAB-MATNR INTO W2_OUTTAB.

W_PRINTTAB-TD1LN = W1_OUTTAB-TDLINE.

W_PRINTTAB-TD2LN = W2_OUTTAB-TDLINE.

W_PRINTTAB-MATNR = W1_OUTTAB-MATNR.

APPEND W_PRINTTAB TO PRINTTAB.

ENDLOOP.

WRITE:/10 TEXT-001, 30 TEXT-002, 80 TEXT-003.

WRITE: / SY-ULINE.

LOOP AT PRINTTAB INTO W_PRINTTAB.

AT NEW MATNR.

WRITE:/ W_PRINTTAB-MATNR UNDER TEXT-001.

ENDAT.

WRITE: 30 W_PRINTTAB-TD1LN , 80 W_PRINTTAB-TD2LN.

SKIP.

ENDLOOP.

Tags:
Not what you were looking for? View more on this topic or Ask a question