Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help Everyone: IDOC Extension Problem

Former Member
0 Likes
2,996

Hi All,

Ive created an idoc extension for idoc type ORDERS01. I appended an extension ZE1EDK01 below header segment E1EDK01. Im trying to populate this through an exit but I cant seem to find the right values for these specifically the segnum and hlevel:

wa_edidd-MANDT = SY-MANDT.

wa_edidd-SEGNUM = '000002'.

wa_edidd-SEGNAM = 'ZE1EDK01'.

wa_edidd-PSGNUM = '000000'.

wa_edidd-HLEVEL = '02'.

wa_edidd-DTINT2 = '1000'.

How do I determine the values above?

Also, I created an extension for item data segment E1EDP01. Im directly modifying the internal table of the IDOC and I want to populate the extension per line item in the idoc. How do I do this? Do I just append entries to EDIDD? How do I ensure that each entry appended corresponds to the correct line item?

Please help. I really need to finish this in 2 hours.

Thank you so much.

Best Regards,

Kenny

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,833

Filling in the SEGNAM and SDATA are the most important things to do. Rest others are not important.

I am assuming that you are using a user exit that is called for each segment record of the IDOC. So you will have a case statement in this user exit for SEGNAM and when it is E1EDP01, you will append the extension record directly underneath it. Typical flow will be SAP fills in the data for one segment, appends it to EDIDD and calls the user exit. So you will always be appending it right after the one that you intend to insert after. I am assuming that you are using IDOC_OUTPUT_ORDERS>PERFORM FUELLEN_IDOC_INTTAB>PERFORM customer_function>CALL CUSTOMER-FUNCTION '002'>EXIT_SAPLEINM_002.

Srinivas

Hi All,

Ive created an idoc extension for idoc type ORDERS01. I appended an extension ZE1EDK01 below header segment E1EDK01. Im trying to populate this through an exit but I cant seem to find the right values for these specifically the segnum and hlevel:

wa_edidd-MANDT = SY-MANDT.

wa_edidd-SEGNUM = '000002'.

wa_edidd-SEGNAM = 'ZE1EDK01'.

wa_edidd-PSGNUM = '000000'.

wa_edidd-HLEVEL = '02'.

wa_edidd-DTINT2 = '1000'.

How do I determine the values above?

Also, I created an extension for item data segment E1EDP01. Im directly modifying the internal table of the IDOC and I want to populate the extension per line item in the idoc. How do I do this? Do I just append entries to EDIDD? How do I ensure that each entry appended corresponds to the correct line item?

Please help. I really need to finish this in 2 hours.

Thank you so much.

Best Regards,

Kenny

12 REPLIES 12
Read only

Former Member
0 Likes
2,834

Filling in the SEGNAM and SDATA are the most important things to do. Rest others are not important.

I am assuming that you are using a user exit that is called for each segment record of the IDOC. So you will have a case statement in this user exit for SEGNAM and when it is E1EDP01, you will append the extension record directly underneath it. Typical flow will be SAP fills in the data for one segment, appends it to EDIDD and calls the user exit. So you will always be appending it right after the one that you intend to insert after. I am assuming that you are using IDOC_OUTPUT_ORDERS>PERFORM FUELLEN_IDOC_INTTAB>PERFORM customer_function>CALL CUSTOMER-FUNCTION '002'>EXIT_SAPLEINM_002.

Srinivas

Read only

0 Likes
2,833

Hi,

Thanks for the reply.

Yes Im using exit EXIT_SAPLEINM_002. but Im not sure if this is being called per line item or its just called once with all the entries in the int_edidd. Please confirm.

For SEGNAM, I dont know what to put. Any ideas?

Thank you so much.

Kenny

Read only

0 Likes
2,833

If you trace the path backwards, you will see in FORM FUELLEN_IDOC_INTTAB.

you will see a loop statement as below. That is where each item segment is created and this user exit is called within that loop for every item segment as well it's child segments.

LOOP AT xekpo.

  • docu: LOOP-begin (item data)

  • docu: general data (segment E1EDP01)

MOVE xekpo TO ekpo.

CLEAR int_edidd.

CLEAR e1edp01.

int_edidd-segnam = 'E1EDP01'.

CLEAR e1edp01-action.

CASE ekpo-loekz.

WHEN 'L'.

....

....

....

SEGNAM will be your segment name.

Read only

0 Likes
2,833

Hi,

Sorry but I think Im having problems with SEGNUM. Im trying to populate segment ZE1EDK01. Im encounterting the error:

EDI: Data records are not numbered sequentially.

How do I know the correct segnum?

Thanks.

Kenny

Read only

0 Likes
2,833

Don't fill in any of those fields, they are not needed. Just fill in SEGNAM with your segment name (ZE1EDK01), and then fill in the structure ZE1EDK01 with data and move ZE1EDK01 to int_edidd-sdata and then do an APPEND int_edidd.

Read only

0 Likes
2,833

Hi Srinivas,

I did what you told me and the fields are populated now. Problem is, the header extension is repeatedly appended in the line items even if its not the header anymore. I want it appended just once. I have this code in the exit.

loop at int_edidd into wa_edidd.

IF wa_edidd-segnam = 'E1EDK01'.

l_edidd-SEGNAM = 'ZE1EDK01'.

CLEAR L_ZE1EDK01.

L_ZE1EDK01-V_NAME1 = 'VENDNAME'.

L_ZE1EDK01-V_TEXT1 = 'TERMS'.

L_ZE1EDK01-V_EKOTX1 = 'PURGROUP'.

l_edidd-SDATA = L_ZE1EDK01.

APPEND l_edidd to int_edidd.

ENDIF.

endloop.

Please help. Thank you so much.

Kenny

Read only

0 Likes
2,833

In the user exit <b><u>do not</u></b> again loop at the int_edidd. Just put a case statement. Use the code below.

CASE int_edidd-segnam.
  WHEN 'E1EDK01'.
    int_edidd-SEGNAM = 'ZE1EDK01'.
    CLEAR L_ZE1EDK01.
    L_ZE1EDK01-V_NAME1 = 'VENDNAME'.
    L_ZE1EDK01-V_TEXT1 = 'TERMS'.
    L_ZE1EDK01-V_EKOTX1 = 'PURGROUP'.
    int_edidd-SDATA = L_ZE1EDK01.
    APPEND int_edidd.
  WHEN 'XXXXXX'.
  WHEN OTHERS.
ENDCASE.

Read only

0 Likes
2,833

Hi,

The code you have given seems right.

Try to use this code and see if you still get multiple header segments.

*--   Constants
DATA: c_e1edk01 LIKE edidd-segman VALUE 'E1EDK01',
      c_ze1edk01 LIKE edidd-segman VALUE 'ZE1EDK01'.

*--   Structure
DATA: lst_ze1edk01 LIKE ze1edk01,
      lst_edidd LIKE edidd.

* Check for header segment
LOOP AT int_edidd.
* check if segment is 'E1EDK01'
  IF int_edidd-segnam = c_e1edk0.

    CLEAR: lst_edidd, lst_ze1edk01.

    lst_ze1edk01-name1 ='VENDNAME'.
    lst_ze1edk01-text1 ='TERMS'.
    lst_ze1edk01-ekotx1 ='PURGROUP'.

    lst_edidd-segman = c_ze1edk01.
    lst_edidd-sdata = lst_ze1edk01.
    APPEND lst_edidd TO int_edidd.
    CLEAR lst_edidd.

  ENDIF.
ENDLOOP.

Let me know if you have any question.

Regards,

RS

Read only

0 Likes
2,833

Hi Srinivas,

Thanks so much. Its working now, I can also use this for the line item extension right?

Also, I have been asking people here to give me a sample outbound idoc program. I am making a customized Idoc type and I want to output it. Its not related to this but I hope you can help.

Thank you so much again.

Best Regards,

Kenny

Read only

0 Likes
2,833

Hi,

I get what is the issue here. <b>It is not because of using CASE statement or IF condition in LOOP</b>.

You are using user-exit EXIT_SAPLEINM_002. This user-exit triggers for each segment added to IDOC. So this is what is happening.

- Segment E1EDK01 is added then user-exit triggers and it adds ZE1EDK01 segment.

- Now the next segment is E1EDK14. After this segment also the exit trigges. When you loop at int_edidd the very first segment is E1EDK01 and it again adds ZE1EDK01 segment.

So, for each segment in IDOC this exit triggers and add segment ZE1EDK01 under E1EDK01.

<b>The solution is to use user-exit EXIT_SAPLEINM_011 instead.</b>

This is very last user-exit which trigges in FM IDOC_OUTPUT_ORDERS and it has all the segment in it. So there is nothing wrong with your code but you are using wrong user-exit.

Let me know if you have any question.

Regards,

RS

Actually Srinivas is also right. If you use the user-exit EXIT_SAPLEINM_002 without using loop command and only using CASE statement it will work. <b>OR</b> you use user-exit EXIT_SAPLEINM_011. Its upto you.

Message was edited by:

RS

Read only

0 Likes
2,833

Yes you can use this for any segment, you will just add another WHEN condition. So I assume this issue is resolved.

Coming to your other question, I hope I have this correct, did you say you have new IDOC TYPE altogether and you want to know how you can create an Idoc for that? That will not be a simple program, but I will see if I can find one for you. Basically what you need to do is that you will have to fill up each of the control record, and segment records yourself. The key function module is MASTER_IDOC_DISTRIBUTE. Do a where-used list for this function module and you may get some idea. The flow will be something like this.

Select the data that you want to put on the IDoc.

Read the partner profiles from EDI13 for outbound IDocs.

Fill in the information for EXPORTING parameter MASTER_IDOC_CONTROL of the function module and fill in the segment data and pass that internal table to MASTER_IDOC_DATA.

Call function MASTER_IDOC_DISTRIBUTE.

Read only

Former Member
0 Likes
2,833

Hi,

Please add the following inside the user exits.

1. Add a check for CONTROL_RECORD_OUT-RCVPRN = <logical system>.

2. If found, set CONTROL_RECORD_OUT-CIMTYP to your extension.


CHECK CONTROL_RECORD_OUT-RCVPRN = 'SAPXI'.

MOVE 'ZORDER01' TO CONTROL_RECORD_OUT-CIMTYP.

Regards,

Ferry Lianto