Hi Experts,
I have a query regarding downloading the PO text from material master.Actually i have successfully downloaded the PO text using TLINE structure along with FM like READ_TEXT and GUI_Download.But when i had to append the PO text for corresponding material,there i got the problem.Let me explain clearly.Below is my coding for PO text download.In that i have used TLINE structure/table for get the POtext via FM READ_TEXT.Also I am using an internal table(It_tab) which consist fields of TDFORMAT,TDLINE and MATNR,So what i need is,i want to merge TLINES structure/table into internal table(it_tab).That is I want to display the PO text along with material No.That is my requirement.But when i append the it_tab using my coding,it was not displaying in the correct order.Attached screen shot is the sample output(excel sheet).column B and C respectively for POtext and material number.I want to get in correct order as it gets the misarrangemnt.(i.e) PO text and material number should come with the same line.So Please help me to complete this task.Kindly point out if i am wrong.
PO TEXT download from material master :
DATA : BEGIN of IT_LINES OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA : END of IT_LINES.
DATA : t_line TYPE STANDARD TABLE OF IT_LINES WITH HEADER LINE.
TYPES: BEGIN OF tp_matnr,
matnr type TDOBNAME,
END OF tp_matnr.
DATA:lv_matnr TYPE matnr,
t_mara TYPE TABLE OF tp_matnr WITH HEADER LINE.
SELECT-OPTIONS : s_matnr FOR lv_matnr.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TL1.
PARAMETERS: P_FILE(50) TYPE C.
*PARAMETERS: P_DOWNL as CHECKBOX.
SELECTION-SCREEN END OF BLOCK BL1.
INITIALIZATION.
TL1 = 'PO TEXT DOWNLOAD'.
START-OF-SELECTION.
SELECT matnr FROM mara INTO TABLE t_mara WHERE matnr IN s_matnr.
DATA : BEGIN OF it_tab OCCURS 0,
TDFORMAT type TDFORMAT,
TDLINE type TDLINE,
MATNR type TDOBNAME,
END OF it_tab.
LOOP AT t_mara.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = 'BEST'
language = 'E'
name = t_mara-matnr
OBJECT = 'MATERIAL'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
* OLD_LINE_COUNTER =
TABLES
lines = t_line
* 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.
APPEND LINES OF t_lineto it_tab.
it_tab-tdline = t_line-tdline.
it_tab-matnr = t_mara-matnr.
APPEND it_tab.
ENDIF.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'D:\Test.xls'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
SHOW_TRANSFER_STATUS = 'X'
TABLES
DATA_TAB = it_tab