Code: Alles auswählen.
DATA: memory_id(30) VALUE 'SAPLSTXD',
lv_header_text TYPE thead,
lt_lines_text TYPE STANDARD TABLE OF tline.
DATA:
BEGIN OF lt_catalog OCCURS 0,
tdobject LIKE thead-tdobject,
tdname LIKE thead-tdname,
tdid LIKE thead-tdid,
tdspras LIKE thead-tdspras,
function(1) TYPE c,
keep(1) TYPE c,
rename(1) TYPE c,
id(6) TYPE n,
copyindex(4) TYPE i,
is_reftext(1) TYPE c,
END OF lt_catalog.
DATA: wa_catalog LIKE LINE OF lt_catalog.
IMPORT catalog TO lt_catalog FROM MEMORY ID memory_id.
READ TABLE lt_catalog INTO wa_catalog INDEX 1.
lv_header_text-tdobject = 'VBBP'.
CONCATENATE wa_catalog-tdname xvbap-posnr INTO lv_header_text-tdname.
lv_header_text-tdid = 'Z001'.
lv_header_text-tdspras = wa_catalog-tdspras.
APPEND INITIAL LINE TO lt_lines_text ASSIGNING FIELD-SYMBOL(<fs_line_text>).
IF sy-subrc IS INITIAL.
<fs_line_text>-tdline = 'Test'.
ENDIF.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = lv_header_text
TABLES
lines = lt_lines_text
EXCEPTIONS
id = 1 " Text-Id in Textheader ungültig
language = 2 " Sprache in Text-Header ungültig
name = 3 " Textname in Texthaeder ungültig
object = 4 " Textobjekt in Textheader ungültig
OTHERS = 5.
IF sy-subrc IS INITIAL.
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = lv_header_text-tdobject
name = lv_header_text-tdname
id = lv_header_text-tdid
language = lv_header_text-tdspras
IMPORTING
commit_count = sy-index.
ENDIF.
Folgende Benutzer bedankten sich beim Autor wreichelt für den Beitrag:
creative235
Folgende Benutzer bedankten sich beim Autor ewx für den Beitrag:
creative235
Code: Alles auswählen.
FORM userexit_move_field_to_vbap.
DATA ls_header TYPE thead.
DATA lt_lines TYPE STANDARD TABLE OF tline.
IF vbap-vbeln IS INITIAL.
ls_header-tdname = 'XXXXXXXXXX' && vbap-posnr.
ELSE.
ls_header-tdname = vbap-vbeln && vbap-posnr.
ENDIF.
ls_header-tdobject = 'VBBP'.
ls_header-tdid = '0001'.
ls_header-tdspras = sy-langu.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = ls_header-tdid
language = ls_header-tdspras
name = ls_header-tdname
object = ls_header-tdobject
local_cat = space
IMPORTING
header = ls_header
TABLES
lines = lt_lines
EXCEPTIONS
OTHERS = 8.
IF sy-subrc <> 0.
lt_lines = VALUE #( ( tdformat = '*' tdline = |ARKTX: { vbap-arktx }| ) ).
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = ls_header
insert = abap_true
savemode_direct = space
local_cat = space
TABLES
lines = lt_lines
EXCEPTIONS
OTHERS = 5.
ENDIF.
ENDFORM.
Folgende Benutzer bedankten sich beim Autor ewx für den Beitrag:
creative235