Application Development 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: 

Sorting Problem in a BADI

Former Member
0 Kudos

Hi Everyone,

I am trying to use VL10D to issue purchase items due for delivery and while doing so I want to sort them based on the storage bin(LGPBE).

I am trying to achieve this by using BADI : LE_SHP_DELIVERY_PROC and method : SAVE_DOCUMENT_PREPARE.

The coding part is simple as I am just using a sort statement.

sort ct_xlips by lgpbe.

When I am debugging it shows me that ct_xlips has been sorted but I dont see any changes in my final result. Can anyone help me in this regard.

Thanks

Kumar.

6 REPLIES 6

Former Member
0 Kudos

Hi Kumar,

Please post the entire source code for review.

Thanks!

0 Kudos
method IF_EX_LE_SHP_DELIVERY_PROC~SAVE_DOCUMENT_PREPARE.

  data : lt_lips TYPE TABLE OF LIPSVB.
  DATA : wa_lips TYPE LIPSVB.
  DATA : l_lgpbe TYPE lgpbe.

  
  loop at ct_xlips into wa_lips.

    select single lgpla from mlgt into  l_lgpbe
                       where matnr = wa_lips-matnr
                          and lgnum = wa_lips-lgnum.
      wa_lips-lgpbe = l_lgpbe.

APPEND wa_lips to lt_lips.

  ENDLOOP.

  sort lt_lips by lgpbe.

  clear ct_xlips.
  CLEAR wa_lips.
  loop at lt_lips INTO wa_lips.
    APPEND wa_lips to ct_xlips.
    ENDLOOP.

endmethod.

0 Kudos

Hi,

What do you actually mean by "Final Result"?

If you mean to say that in the output of VL10D trasaction, LIPS data is not sorted according to your sorting criteria then it is because standard SAP always sorts Line Item data based on the Primary keys and/or Item Number.

This might be the probable reason why in the final result you are not getting the output in the desired order.

Regards,

Abhisek.

0 Kudos

@Abraham and Abhishek

The main problem is the output gets printed in a smartform and I want the items on the smartform to get sorted based on the storage bin. The structure on the smartform doesnt allow me to do that and it gives me an error saying that IS_DLV_DELNOTE is of type Sorted and I cannot sort it. So I was trying to sort it before it even goes there. Maybe my approach itself is wrong.

Thanks

Kumar.

Former Member
0 Kudos

Have you try to debug and check whether there is another sort statement in SAP standard program after your BADI is called? Maybe SAP already has its own sorting for the table that is executed after the BADI.

Regards,

Abraham

Former Member
0 Kudos

Not solved