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

Sort IDOC segment problem

Former Member
0 Likes
1,290

Hi Idoc Experts!

Just want to know you opinion on how to sort the Idoc Internal table shown below. I am trying to sort the internal table int_edidd by edatub after it has appended new entries.


      LOOP AT int_edidd INTO wa_int_edidd
        WHERE segnam(7) = 'E2EDP16'.
      ENDLOOP.
      IF sy-subrc = 0.
        MOVE wa_int_edidd-sdata TO e1edp16.
        IF delinquent_demand IS NOT INITIAL.                 
          e1edp16-edatuv = sy-datlo.
          e1edp16-edatub = sy-datlo.
          e1edp16-ettyp  = ' '.                              
          e1edp16-wmeng = delinquent_demand.
          MOVE e1edp16 TO wa_int_edidd-sdata.
          wa_int_edidd-segnum = wa_int_edidd-segnum + 1.
          APPEND wa_int_edidd TO int_edidd.
        ENDIF.                                               
        IF delinquent_demand_f IS NOT INITIAL.               
          e1edp16-edatuv = sy-datlo.                         
          e1edp16-edatub = sy-datlo.                         
          e1edp16-ettyp  = 'F'.                              
          e1edp16-wmeng = delinquent_demand_f.               
          MOVE e1edp16 TO wa_int_edidd-sdata.                
          wa_int_edidd-segnum = wa_int_edidd-segnum + 1.     
          APPEND wa_int_edidd TO int_edidd.                  
        ENDIF.                                               
      ENDIF.

<b><u>E1EDP16 SEGMENT structure</u></b>
ETTYP		CHAR	1
PRGRS		CHAR	1
EDATUV		CHAR	8
EZEIT		CHAR	4
EDATUB		CHAR	8
ETVTF		CHAR	2
WMENG		CHAR	15
FZABR		CHAR	15
BSTAS		CHAR	1
WDATUV		CHAR	8
WZEIT		CHAR	4
WDATUB		CHAR	8

Best Regards,

JP

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
985

Hi JP,

It is not advised to sort the IDOC internal table as the data is depend on the segment types so if you sort the sequence of segment may differ than standard and may result in errors.

Regards,

Atish

6 REPLIES 6
Read only

Former Member
0 Likes
986

Hi JP,

It is not advised to sort the IDOC internal table as the data is depend on the segment types so if you sort the sequence of segment may differ than standard and may result in errors.

Regards,

Atish

Read only

0 Likes
985

Hi Atish,

Thnx for the quick reply. Is there any way i can sort the SDATA of the segment pulled in the loop (e.g E1EDP16) ?

Best Regards,

JP

Read only

0 Likes
985

anyone??

rgs, JP

Read only

0 Likes
985

Hi,

May be try this way.


INSERT Itab index 4. 

      LOOP AT int_edidd INTO wa_int_edidd
        WHERE segnam(7) = 'E2EDP16'.
      ENDLOOP.
      v_tabix = sy-tabix.  "<<<<
      IF sy-subrc = 0.
        MOVE wa_int_edidd-sdata TO e1edp16.
        IF delinquent_demand IS NOT INITIAL.                 
          e1edp16-edatuv = sy-datlo.
          e1edp16-edatub = sy-datlo.
          e1edp16-ettyp  = ' '.                              
          e1edp16-wmeng = delinquent_demand.
          MOVE e1edp16 TO wa_int_edidd-sdata.
          wa_int_edidd-segnum = wa_int_edidd-segnum + 1.
          insert int_edidd from wa_int_edidd index v_tabix. "<<<<
*          APPEND wa_int_edidd TO int_edidd.
        ENDIF.                                               
        IF delinquent_demand_f IS NOT INITIAL.               
          e1edp16-edatuv = sy-datlo.                         
          e1edp16-edatub = sy-datlo.                         
          e1edp16-ettyp  = 'F'.                              
          e1edp16-wmeng = delinquent_demand_f.               
          MOVE e1edp16 TO wa_int_edidd-sdata.                
          wa_int_edidd-segnum = wa_int_edidd-segnum + 1.     
          insert int_edidd from wa_int_edidd index v_tabix. "<<<<
*          APPEND wa_int_edidd TO int_edidd.                  
        ENDIF.                                               
      ENDIF.

a®

Read only

0 Likes
985

yeah!!!! it worked!!! tnx

Best regards,

JP

Read only

0 Likes
985

Hello JP,

How did the SORT work, after you had entries in int_edidd? Can you help me on this?

Thanks,

SG