cancel
Showing results for 
Search instead for 
Did you mean: 

changing sort order of SC items?

Former Member
0 Kudos

Hi everybody

Just got a new request from our end users: is it possible to change the sort order of SC items?

They would like to have SC items being sorted in alphabetical order. It is especially requested for standard and/or personal SC templates or any other old SC and would make it much easier for our end users to find items in templates (we're talking about templates with up to 400 items!).

It is not necessary and not wanted to change sort order every time a new item is added to the SC... just when parking or saving it.

I was thinking about BAdI BBP_DOC_CHECK_BADI or BBP_DOC_SAVE. Is it possible from there to read the SC content into internal table, to change sort order and to store the SC with alphabetically sorted items?

Did someone out there already implement a similar logic and is willing to share some example code?

TIA and best regards,

Renaud

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello

Long time ago... just wanted to let you know how I solved it:

1. Couldn't use BBP_DOC_CHANGE_BADI because I didn't find out how to know whether or not I'm saving or parking... and I only wanted to change sort order of line items in either case.

2. So I used BBP_DOC_CHECK_BADI and checked for I_SAVE = 'X' or I_PARK = 'X' before reading SC details with function module BBP_PD_SC_GETDETAIL. Then changed sort order of line items (internal table E_ITEMS) and passed everything to function module BBP_PD_SC_UPDATE.

This did the trick...

Regards,

Renaud

Former Member
0 Kudos

Hi

<i>Sounds interesting, like the user requirement.

This seems to be nice approach and will definitely solve the problem.</i>

<b>Inside BBP_DOC_CHANGE_BADI, put the last line to sort the

data in alphabetical order, i.e.,

here is the one line code...</b>

sort et_items by object_id           ascending  " shopping cart no
                        description_uc    ascending " short cat description.              

<b>So once the user will do anything with the shopping cart, say check, refresh, hold or save, the data will always be sorted in ascending order, as per your requirement.</b>

Hope this will also help.

Let me know incase you need any other information.

Regards

- Atul

Former Member
0 Kudos

Hi Atul

Unfortunately our users want to work on SC content without changing the sort order. They only want to have it sorted in alphabetical order when ordering, saving as template or parking the SC.

I didn't find out how to achieve this using BBP_DOC_<b>CHANGE</b>_BADI. This BAdI doesn't offer IV_MODE, IV_SAVE, IV_PARK flags.

BTW: be careful to call BBP_PD_SC_UPDATE in BBP_DOC_<b>CHECK</b>_BADI without checking IV_SAVE and IV_PARK else you'll most probable end up in an endless loop because in BBP_PD_SC_UPDATE the BBP_DOC_<b>CHANGE</b>_BADI is called again.

And one more thing: when sorting the SC items you have renumber field NUMBER_INT else the sort order will be reverted somewhere after passing through your BAdI coding.

Kind regards,

Renaud

Former Member
0 Kudos

Hi

This seems to be quite interesting requirement.

<b>In the BBP_DOC_CHECK_BADI, put a condition like this</b>

IF IV_SAVE    = 'X'
OR  IV_PARK  = 'X.

sort et_items by object_id           ascending  " shopping cart no
                        description_uc    ascending " short cat description.          

ENDIF.

Hope this will help.

Please reward suitable points.

Regards

- Atul

Former Member
0 Kudos

Hi,

BBP_DOC_CHECK_BADI is used to put validations for the SC data.So you may have to use the Badi BBP_DOC_CHANGE_BADI.There you can sort the item table and pass it to the changing parameters.

I have no idea on BBP_DOC_SAVE but definately this reqt can be fulfilled through BADI.

BR,

Disha.

Pls reward points for helpful answers.

Former Member
0 Kudos

dear renaud

This is possible with BBP_DOC_CHECK_BADI and BBP_DOC_CHANGE_BADI

Look for shopping cart when it is order before saving the SC say if there are 400 lines items then take all in an internal table sort them and pass the new sequence to the final updating FM which will in turn save the SC in same sort.

we have not done this however this is possible through badi .

regards,

Nimish Sheth