Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to restrict Standard/Custom Segment triggering from Multiple Times

Hi,

Find the piece of code below as per my requirement regarding adding Idoc Zsegments and fields.

Its working fine.

*Getting the Delivery Document Number and assigning it to the Where Clause

FIELD-SYMBOLS: <FS_EDIDD> TYPE EDIDD.

READ TABLE IDOC_DATA ASSIGNING <FS_EDIDD> WITH KEY SEGNAM = 'E1EDL20'.

IF <FS_EDIDD> IS ASSIGNED.

   LS_E1EDL20 = <FS_EDIDD>-SDATA.      "Delivery Document Number

ENDIF.

*1*Fetching the respective fields for IDoc: Delivery header

SELECT SINGLE VBELN LIFNR ZZASNNO ZZINVOIVE_NO ZZREASON FROM LIKP INTO LS_LIKP WHERE VBELN = LS_E1EDL20-VBELN.

CHECK SY-SUBRC = 0.

*1****************************************Delivery header******************************1

READ TABLE IDOC_DATA INTO ls_edidd WITH KEY segnam = 'E1EDL20'.   "Custom Segment Position

CHECK SY-SUBRC = 0.

lv_tabix = sy-tabix + 1.

CONCATENATE LS_LIKP-ZZASNNO+0(20) LS_LIKP-ZZINVOIVE_NO+0(10) LS_LIKP-ZZREASON+0(20) INTO lv_sdata1.

ls_edidd-sdata = lv_sdata1.

ls_edidd-segnam = co_E1EDL20.

INSERT ls_edidd INTO IDOC_DATA INDEX lv_tabix.

CHECK sy-subrc = 0.

CLEAR: LS_LIKP,

        lv_sdata1,

        ls_edidd.


Doubt: As Respective "Include -   zxtrku02" is triggering multiple times and so my "segment E1EDL20"/Zsegment ZE1EDL20.


How to restrict my standard segment E1EDL20 and its custom segment ZE1EDL20 from triggering mutiple times.

Kindly let me know ASAP.

Idoc Details:

Message Type: DESADV

Basic Type: DELVRY03

Outbound Process Code: DELV

Output Type: OPOD

Function Module - IDOC_OUTPUT_DELVRY

Customer Exit - customer-function '002'

FM Exit name - EXIT_SAPLV56K_002

Include -   zxtrku02

With Regards,

Sudhir.

Former Member replied

Hi Sudhir,

Since the previous thread is already completed, hence responding on the new one.


SCENARIO 1

SEGMENT_NAME is already declared in Function module as EDIDD-SEGNAM.

You need to use it in your include. Using below code, the customer exit 002 will be called only when segment E1EDL20 is called. For other segments, the same exit is called but due to this check, the code wont be executed and your functionality will be achieved.

IF segment_name = 'E1EDL20'.

     "Your entire piece of code

ENDIF.

SCENARIO 2

If E1EDL20 segment is being triggered multiple times, then please use below code. (Though this scenario might not happen)

IF segment_name = 'E1EDL20'.

READ TABLE IDOC_DATA INTO ls_edidd WITH KEY segnam = 'ZE1EDL20'.   "Custom Segment

IF sy-subrc = 0.

     EXIT.

ELSE.

     "Your entire piece of code

ENDIF.

ENDIF.

Regards,

Aashika

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question