Skip to Content
0
Former Member
Feb 05, 2014 at 04:33 AM

READ_TEXT Is Not Working After Update Long Text by "CRM_ORDER_MAINTAIN"

107 Views

Hello,

I am updating long text of opportunity by using CRM_ORDER_MAINTAIN, but after successfully update READ_TEXT is not working in same program.

Please help and correct my below code or suggest any other option for read long text in same program after update.

TYPES: BEGIN OF T_LINE,
LINE(132) TYPE C,
END OF T_LINE.

DATA:IT_TEXT TYPE CRMT_TEXT_COMT,
IT_TEXT1 TYPE CRMT_TEXT_COM.

DATA:CT_ORDERADM_H TYPE CRMT_ORDERADM_H_COMT,
CT_ORDERADM_H1 TYPE CRMT_ORDERADM_H_COM.

DATA: ls_input_fields TYPE CRMT_INPUT_FIELD, "CRMT_STATUS_COM."CRMT_STATUS_COMT.
ls_input_field_names TYPE CRMT_INPUT_FIELD_NAMES,
CT_INPUT_FIELDS TYPE CRMT_INPUT_FIELD_TAB.

DATA: IT_OBJECTS_TO_SAVE TYPE CRMT_OBJECT_GUID,
IT_OBJECTS_TO_SAVE1 TYPE CRMT_OBJECT_GUID_TAB,
ET_SAVED_OBJECTS TYPE CRMT_RETURN_OBJECTS,
ET_SAVED_OBJECTS1 TYPE CRMT_RETURN_OBJECTS_STRUC.

DATA: lt_line TYPE STANDARD TABLE OF tline,
ls_line TYPE tline,
lv_name TYPE TDOBNAME.

DATA: GT_LINE TYPE STANDARD TABLE OF T_LINE,
GS_LINE TYPE T_LINE.

data:
lt_header_guid TYPE CRMT_OBJECT_GUID_TAB,
ls_header_guid type CRMT_OBJECT_GUID,
lt_text TYPE CRMT_TEXT_WRKT,
LS_TEXT TYPE CRMT_TEXT_WRK,
LT_SERVICE_OS type CRMT_SRV_OSSET_WRKT,
cv_log_handle TYPE BALLOGHNDL,
ls_requested TYPE CRMT_OBJECT_NAME,
lt_requested TYPE CRMT_OBJECT_NAME_TAB.


ls_input_fields-ref_guid = '005056AE372B1ED397990F34C5495360'.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'TEXTS'.
ls_input_fields-LOGICAL_KEY ='A002E'.
ls_input_field_names-fieldname = 'LINES'.
INSERT ls_input_field_names
INTO TABLE ls_input_fields-field_names.
CLEAR ls_input_field_names.
INSERT ls_input_fields INTO TABLE CT_INPUT_FIELDS."lt_input_fields.
CLEAR ls_input_fields.

ls_input_fields-ref_guid = '005056AE372B1ED397990F34C5495360'.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'ORDERADM_H'.
ls_input_field_names-fieldname = 'POSTING_DATE'.
INSERT ls_input_field_names
INTO TABLE ls_input_fields-field_names.
CLEAR ls_input_field_names.
INSERT ls_input_fields INTO TABLE CT_INPUT_FIELDS."lt_input_fields.
CLEAR ls_input_fields.

CLEAR:GT_LINE[], GS_LINE.
GS_LINE-LINE = 'TESTING BY KSHITIJ'.
APPEND GS_LINE TO GT_LINE.

CLEAR:GS_LINE.
GS_LINE-LINE = 'UPDATE OPPORTUNITY'.
APPEND GS_LINE TO GT_LINE.
CLEAR GS_LINE.

CLEAR LT_LINE[].
LOOP AT GT_LINE INTO GS_LINE.
LS_LINE-TDFORMAT = '*'.
LS_LINE-TDLINE = GS_LINE-LINE.
APPEND LS_LINE TO LT_LINE.
ENDLOOP.



CLEAR:IT_TEXT1,IT_TEXT[].
IT_TEXT1-REF_GUID = '005056AE372B1ED397990F34C5495360'.
IT_TEXT1-REF_KIND = 'A'.
IT_TEXT1-TEXT_OBJECT = 'CRM_ORDERH'.
IT_TEXT1-TDID = 'A002'.
IT_TEXT1-TDSPRAS = 'E'.
IT_TEXT1-TDSTYLE = 'SYSTEM'.
IT_TEXT1-TDFORM = 'SYSTEM'.
IT_TEXT1-LINES = LT_LINE[].
IT_TEXT1-MODE = 'A'.
* IT_TEXT1-MODE = 'B'.
APPEND IT_TEXT1 TO IT_TEXT.

CT_ORDERADM_H1-GUID = '005056AE372B1ED397990F34C5495360'.
CT_ORDERADM_H1-POSTING_DATE = '20131226'.
APPEND CT_ORDERADM_H1 TO CT_ORDERADM_H.
CLEAR CT_ORDERADM_H1.


CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
IT_TEXT = IT_TEXT
CHANGING
CT_ORDERADM_H = CT_ORDERADM_H
* CT_ORDERADM_I = CT_ORDERADM_I
CT_INPUT_FIELDS = CT_INPUT_FIELDS
EXCEPTIONS
ERROR_OCCURRED = 1
DOCUMENT_LOCKED = 2
NO_CHANGE_ALLOWED = 3
NO_AUTHORITY = 4
OTHERS = 5
.

CLEAR:ET_SAVED_OBJECTS1,ET_SAVED_OBJECTS[].
ET_SAVED_OBJECTS1-GUID = '005056AE372B1ED397990F34C5495360'.
ET_SAVED_OBJECTS1-OBJECT_ID = '0006001070'.
APPEND ET_SAVED_OBJECTS1 TO ET_SAVED_OBJECTS.

CLEAR:IT_OBJECTS_TO_SAVE,IT_OBJECTS_TO_SAVE1[].
IT_OBJECTS_TO_SAVE = '005056AE372B1ED397990F34C5495360'.
APPEND IT_OBJECTS_TO_SAVE TO IT_OBJECTS_TO_SAVE1.


CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
IT_OBJECTS_TO_SAVE = IT_OBJECTS_TO_SAVE1

IMPORTING
ET_SAVED_OBJECTS = ET_SAVED_OBJECTS

EXCEPTIONS
DOCUMENT_NOT_SAVED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
ENDIF.

WAIT UP TO 1 SECONDS.

CLEAR LT_LINE[].
LV_NAME = '005056AE372B1ED397990F34C5495360'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'A002'
language = sy-langu
name = lv_name "(GUID OF OPPORTUNITY)
object = 'CRM_ORDERH'
ARCHIVE_HANDLE = '0'
LOCAL_CAT = ' '
TABLES
lines = lt_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 EQ 0.

ENDIF.


Regards,

Kshitij Rathore

+91-8087340641