2015 May 05 10:51 AM
Hello.
I have a problem with smartforms.
I need to sort items in invoice by lowerst price to high, and i need to merge duplicate items.
Someone can help me?
2015 May 05 11:12 AM
Hi,
If you are using report/print/driver program, then before passing the data to smartform, you can sort the values and pass. if not, after consuming the data into smartform, as told by vijaykrishna you can add the code node and write a code to sort the values before displaying.
Cheers!!
Rita
2015 May 05 11:06 AM
Hi, Sorting has to be done in the report level itself or in Smartform insert Code node and write the logic in that.
Regards,
Vijay
2015 May 05 11:12 AM
Hi,
If you are using report/print/driver program, then before passing the data to smartform, you can sort the values and pass. if not, after consuming the data into smartform, as told by vijaykrishna you can add the code node and write a code to sort the values before displaying.
Cheers!!
Rita
2015 May 05 12:25 PM
IF cf_retcode = 0.
* select print data
PERFORM get_data USING ls_print_data_to_read
CHANGING ls_addr_key
ls_dlv-land
ls_bil_invoice
cf_retcode.
This is the place where can i sort?
2015 May 05 12:30 PM
Hi,
actually the code you posted is not good enough to tell you is that the place to sort or not.
As of my understanding, in the mentioned sub-routine you are fetching the data. If so, you can sort the table as per your requirement after the Perform statement as table will be filled in Routine. If not, you need to post the appropriate code by mentioning that where have you written.
Regards,
Vijay
2015 May 05 12:54 PM
Hi,
I think you are talking about the structure "ls_bill_invoice" in the perform statement. if you are passing the same to smartform, then you can sort the same after perform statement or within "Form Endform".
I stil have so many doubts. Can you please post the code where you want to sort and merge the duplicates.. would like to know what does that perform get data does according to you.
To make it simple, just sort the internal table which has data in it before passing to smartform. You will be passing the data to smartform using " Call Function <formname>" check in that part of code.
2015 May 05 1:02 PM
As for the merging of the duplicates you can use DELETE ADJACENT DUPLICATES FROM itable COMPARING ALL FIELDS after sorting the internal table you pass to the smartform. It will leave you with only the rows that are unique.
Regards,
Noa
2015 May 05 1:35 PM
Since this is for an invoice, I would guess that the lines might include quantity and total amount. In that case, merging the lines isn't solved by deleting adjacent duplicates; you would need to COLLECT the entries into a separate itab in order to get correct total quantity and amount per item.
Jim
2015 May 05 2:57 PM
Hi,
View the image.
Creating loop you can add the fields for sorting.
Hope it helpful,
Regards,
VenkatRamesh
2015 May 07 7:53 AM
2015 May 07 8:15 AM
LOOP AT ls_bil_invoice-it_price INTO ls_price.
APPEND ls_price TO lt_price.
ENDLOOP.
clear ls_bil_invoice-it_price[].
SORT lt_price
ascending BY netwr.
LOOP at lt_price into ls_price.
ls_price-itm_number = sy-tabix + 10.
append ls_price to ls_bil_invoice-it_price.
endloop.
This is source code for sort, now i need only merging.