Greeting,
I am trying to use FM" READ_TEXT to get text from header of sales order, then save into custom table, however, I found the data between internal table & custom table are different as below screen shot:
different-data-between-it-custom-table.png
My program as below:
====================================================================================
REPORT ztext_read.
DATA: itab TYPE TABLE OF zsoheader,
ttab LIKE TABLE OF tline WITH HEADER LINE.
DATA: name LIKE thead-tdname,
language LIKE stxh-tdspras.
TYPES:
BEGIN OF st_vbak,
vbeln TYPE vbeln_va,
bstnk TYPE bstnk,
kunnr TYPE zcusname,
name1 TYPE name1_gp,
audat TYPE audat,
fmbdat TYPE mbdat,
END OF st_vbak,
BEGIN OF st_stxh,
tdname TYPE tdobname,
ztext TYPE ztext,
tdspras TYPE spras,
END OF st_stxh,
BEGIN OF st_header,
vbeln TYPE vbeln_va,
bstnk TYPE bstnk,
kunnr TYPE zcusname,
name1 TYPE name1_gp,
audat TYPE audat,
fmbdat TYPE mbdat,
ztext TYPE ztext,
tdspras TYPE spras,
END OF st_header.
DATA:
it_vbak TYPE TABLE OF st_vbak WITH HEADER LINE,
wa_vbak TYPE st_vbak,
it_stxh TYPE TABLE OF st_stxh WITH HEADER LINE,
wa_stxh TYPE st_stxh,
it_header TYPE TABLE OF st_header WITH HEADER LINE,
wa_header TYPE st_header.
SELECT * FROM zsoheader INTO TABLE itab WHERE audat = sy-datum.
DELETE zsoheader FROM TABLE itab.
SELECT t1~vbeln t1~bstnk t1~kunnr t2~name1 t1~audat t1~fmbdat FROM vbak AS t1
INNER JOIN kna1 AS t2 ON t1~kunnr = t2~kunnr
INTO TABLE it_vbak
WHERE t1~audat = '20210520'.
IF it_vbak IS NOT INITIAL.
SELECT tdname tdspras FROM stxh INTO TABLE it_stxh WHERE tdname = it_vbak-vbeln.
ENDIF.
LOOP AT it_vbak INTO wa_vbak.
IF it_stxh IS INITIAL.
wa_stxh-tdname = wa_vbak-vbeln.
wa_stxh-tdspras = 'M'.
APPEND wa_stxh TO it_stxh.
CLEAR wa_stxh.
ENDIF.
ENDLOOP.
LOOP AT it_stxh INTO wa_stxh..
name = wa_stxh-tdname.
language = wa_stxh-tdspras.
PERFORM read_text TABLES ttab
USING '0001'
'VBBK'
name.
IF ttab IS INITIAL.
wa_stxh-ztext = 'none'.
ELSE.
wa_stxh-ztext = ttab-tdline .
ENDIF.
MODIFY it_stxh FROM wa_stxh TRANSPORTING ztext.
ENDLOOP.
LOOP AT it_vbak INTO wa_vbak.
LOOP AT it_stxh INTO wa_stxh WHERE tdname = wa_vbak-vbeln.
wa_header-vbeln = wa_vbak-vbeln.
wa_header-bstnk = wa_vbak-bstnk.
wa_header-kunnr = wa_vbak-kunnr.
wa_header-name1 = wa_vbak-name1.
wa_header-audat = wa_vbak-audat.
wa_header-fmbdat = wa_vbak-fmbdat.
wa_header-ztext = wa_stxh-ztext.
wa_header-tdspras = wa_stxh-tdspras.
APPEND wa_header TO it_header.
CLEAR wa_header.
ENDLOOP.
ENDLOOP.
INSERT zsoheader FROM TABLE it_header.
************************************************************************
* READ_TEXT.
************************************************************************
FORM read_text TABLES tab
USING id
object
name.
DATA: BEGIN OF header.
INCLUDE STRUCTURE thead.
DATA: END OF header.
CLEAR tab. REFRESH tab.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = id
language = language
name = name
object = object
IMPORTING
header = header
TABLES
lines = tab
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
ENDFORM. "read_text
====================================================================================
Could you please help me to solve this issue?
Thanks & Best Regards
Roger
Request clarification before answering.
| User | Count |
|---|---|
| 14 | |
| 13 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.