2014 Jul 01 8:27 AM
Hi friends,
I have to Change Structure Fields position dynamically in Internal table.....
Ex. Structure.
types: begin of ty_stru,
werks type werks,
lifnr type lifnr,
name type name1,
amoun type dmbtr,
end begin of ty_stru.
data: it_stru type table of ty_stu,
wa_stru type ty_stu.
My Requirement is, i have to get sum of Amount in 2 cases(2 type O/P)
Output 1) Sum of All Plants. : In Diff Plants there ll be Same Vendor.
Output 2) Sum of All Vendors.
Is there any options to change Structure Fields Positions Dynamically....
To Use Control Break Command: At End
Thanks & Regards,
Bhargav D.
2014 Jul 01 9:00 AM
DATA: it_stru type table of ty_stu,
it_werks type hashed table of ty_stu with unique key werks, "Contains total per plant
it_lifnr type hashed table of ty_stu with unique key lifnr, "Contains total per vendor
wa_stru type ty_stu,
lv_lifnr type lifnr.
LOOP AT it_stru INTO wa_stru.
lv_lifnr = wa_stru-lifnr.
CLEAR: wa_stru-lifnr, wa_stru-name.
COLLECT wa_stru INTO lt_werks.
CLEAR wa_stru-werks.
wa_stru-lifnr = lv_lifnr.
COLLECT wa_stru INTO lt_lifnr.
ENDLOOP.
2014 Jul 01 8:30 AM
Hi,
I think you have a very bad idea.
Stop playing with AT END.
Just create two internal table with Plants / Vendors and the amount. And play witth the COLLECT statement. That will be more simpler, more faster ...
(or create a copy of your table, clear the field you didn't want, and play witht the AT END)
regards
Fred
2014 Jul 01 9:21 AM
I think this is a very good example of how we can use HASHED TABLEs (because the key - Plant, CoCd, Vendor is unique).
Just create two internal table with Plants / Vendors and the amount. And play witth the COLLECT statement.
I would define different hashed tables (statically/dynamically using RTTC) using the relevant field on which the summation has to be done & fill them using COLLECT.
BR,
Suhas
2014 Jul 01 9:34 AM
I never used this kind of tables, maybe it's a good idea to post a good doc/example
regards
Fred
2014 Jul 01 10:12 AM
Hi,
I like to define only on structure for this requirement...
with diff internal tables......
Actual Requirement is
| Selection Screen | Total Sales for Month | ||
| . | Period | I/P | |
| 1 | Radio Buttons1 | Company | |
| 2 | Radio Buttons2 | Plant | |
| 3 | Radio Buttons3 | Division | |
| 4 | Radio Buttons4 | Vendor | |
| They want O/P | |||
| If Radio Buttons1 | Company1 | Amount | Qty |
| " | Company2 | Amount | Qty |
| " | Company3 | Amount | Qty |
| " | Company4 | Amount | Qty |
| If Radio Buttons2 | Plant1 | Amount | Qty |
| " | Plant2 | Amount | Qty |
| " | Plant3 | Amount | Qty |
| If Radio Buttons3 | Division1 | Amount | Qty |
| " | Division2 | Amount | Qty |
| " | Division3 | Amount | Qty |
| If Radio Buttons4 | Vendor1 | Amount | Qty |
| " | Vendor2 | Amount | Qty |
| " | Vendor3 | Amount | Qty |
| " | Vendor4 | Amount | Qty |
| " | Vendor5 | Amount | Qty |
Thanks & Regards,
Bhargav D.
2014 Jul 01 8:32 AM
Hello,
Will it be an ALV Grid output?
If so, the user already can do the summation himself.
If you have to do the summation in ABAP, you can define another internal table having just "werks, lifnr, amount" and do the summation in a loop.
Regards
Ali Murat
2014 Jul 01 8:46 AM
Hi,
I like to define only on structure for this requirement...
with diff internal tables......
Actual Requirement is
| Selection Screen | Total Sales for Month | ||
| . | Period | I/P | |
| 1 | Radio Buttons1 | Company | |
| 2 | Radio Buttons2 | Plant | |
| 3 | Radio Buttons3 | Division | |
| 4 | Radio Buttons4 | Vendor | |
| They want O/P | |||
| If Radio Buttons1 | Company1 | Amount | Qty |
| " | Company2 | Amount | Qty |
| " | Company3 | Amount | Qty |
| " | Company4 | Amount | Qty |
| If Radio Buttons2 | Plant1 | Amount | Qty |
| " | Plant2 | Amount | Qty |
| " | Plant3 | Amount | Qty |
| If Radio Buttons3 | Division1 | Amount | Qty |
| " | Division2 | Amount | Qty |
| " | Division3 | Amount | Qty |
| If Radio Buttons4 | Vendor1 | Amount | Qty |
| " | Vendor2 | Amount | Qty |
| " | Vendor3 | Amount | Qty |
| " | Vendor4 | Amount | Qty |
| " | Vendor5 | Amount | Qty |
Thanks & Regards,
Bhargav D.
2014 Jul 01 9:22 AM
Is this is a classical report or an ALV?
If the latter, why can't you use the subtotal functionality?
2014 Jul 01 10:33 AM
If that's the case just declare a simple structure like below. Then pass the values based on your radio button selection.
TYPES:
BEGIN OF ty,
field TYPE char18,
amount TYPE dmbtr,
ENDIF.
2014 Jul 01 9:00 AM
DATA: it_stru type table of ty_stu,
it_werks type hashed table of ty_stu with unique key werks, "Contains total per plant
it_lifnr type hashed table of ty_stu with unique key lifnr, "Contains total per vendor
wa_stru type ty_stu,
lv_lifnr type lifnr.
LOOP AT it_stru INTO wa_stru.
lv_lifnr = wa_stru-lifnr.
CLEAR: wa_stru-lifnr, wa_stru-name.
COLLECT wa_stru INTO lt_werks.
CLEAR wa_stru-werks.
wa_stru-lifnr = lv_lifnr.
COLLECT wa_stru INTO lt_lifnr.
ENDLOOP.
2014 Jul 01 10:00 AM
Hi Bhargav,
If u want to use single structure , then Dynamic table help u to do so.
But it became complex program .
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG =
IMPORTING
EP_TABLE = .
Regards
Alok
2014 Jul 01 10:23 AM
In that case, it's bad ideas to declare structure at the begging. If I were you , I would rather use RTTS to play with.
Best Regards.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |