0% found this document useful (0 votes)
109 views3 pages

SAP Order Header Text Update

This document contains code to update the long text for an order header notification. It reads the existing long text, appends additional text lines to an internal table, and then saves and commits the updated long text.

Uploaded by

Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views3 pages

SAP Order Header Text Update

This document contains code to update the long text for an order header notification. It reads the existing long text, appends additional text lines to an internal table, and then saves and commits the updated long text.

Uploaded by

Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

*&---------------------------------------------------------------------*

*& Report ZTRK_TEST2


*&
*&---------------------------------------------------------------------*
*&TO UPDATE ORDER HEADER LONG TEXT

*&
*&---------------------------------------------------------------------*

REPORT ztrk_test2.

DATA: es_header TYPE thead,


gs_thead TYPE thead,
es_lines TYPE tline,
gs_tline TYPE tline,
gs_tline1 TYPE tline,
* gs_tline1 TYPE tline,
et_lines TYPE TABLE OF tline,
gt_tline TYPE TABLE OF tline,
gt_tline1 TYPE TABLE OF tline,
wa_aufk TYPE aufk,
gt_comments_long_texts1 TYPE alm_me_bapi2080_notfulltxti_t,
gs_long_texts TYPE bapi2080_notfulltxti,
lv_test TYPE c.

CONSTANTS:gc_qmel(4) TYPE c VALUE 'QMEL',


gc_ltxt(4) TYPE c VALUE 'LTXT',
gc_en(2) TYPE c VALUE 'EN',
gc_pm_qmel(7) TYPE c VALUE 'PM_QMEL',
gc_x TYPE c VALUE 'X'.

CLEAR:gs_thead,gs_tline.

*** Update header text for notification


gs_thead-tdobject = 'AUFK'.
gs_thead-tdname = '120002300000029'."ip_jv_header1-qmnum.
gs_thead-tdid = 'KOPF'.
gs_thead-tdspras = sy-langu."gc_en.
*gs_thead-tdform = gc_pm_qmel.

REFRESH gt_tline.

*-- Filling Long Text internal table


LOOP AT gt_comments_long_texts1 INTO gs_long_texts.

gs_tline-tdformat = '*'.
gs_tline-tdline = gs_long_texts-text_line.
APPEND gs_tline TO gt_tline.
CLEAR:gs_long_texts,gs_tline.

ENDLOOP.

CALL FUNCTION 'READ_TEXT'


EXPORTING
client = sy-mandt
id = gs_thead-tdid
language = sy-langu
name = gs_thead-tdname
object = gs_thead-tdobject
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
* OLD_LINE_COUNTER =
TABLES
lines = gt_tline1
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 gt_tline1 INTO gs_tline1.


**
** CLEAR gs_tline.
** gs_tline-tdformat = '*'.
** gs_tline-tdline = gs_tline1-tdline.
** APPEND gs_tline TO gt_tline.
** CLEAR:gs_tline1,gs_tline.
**
**ENDLOOP.
CLEAR lv_test.
IF gt_tline1[] IS NOT INITIAL.
lv_test = 'X'.
ENDIF.

*
*** Save reason entered as header text for notification
IF lv_test EQ 'X'.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = gs_thead
* insert =
savemode_direct = gc_x
TABLES
lines = gt_tline[]
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.

ELSE.

CALL FUNCTION 'SAVE_TEXT'


EXPORTING
client = sy-mandt
header = gs_thead
insert = 'X'
savemode_direct = gc_x
TABLES
lines = gt_tline[]
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.

ENDIF.

CALL FUNCTION 'COMMIT_TEXT'


EXPORTING
object = gs_thead-tdobject"es_header-tdobject
name = gs_thead-tdname"es_header-tdname
id = gs_thead-tdid"es_header-tdid
language = sy-langu"es_header-tdspras
savemode_direct = ' '
* KEEP = ' '
* LOCAL_CAT = ' '
* IMPORTING
* COMMIT_COUNT =
* TABLE
* T_OBJECT =
* T_NAME =
* T_ID =
* T_LANGUAGE =
.

COMMIT WORK AND WAIT.

You might also like