‎2014 Jan 07 7:32 PM
Hi All,
I am new to ABAP.
I have requirement where I have to fill data into an internal table and based upon the internal table data I have fetch details from others tables and show it in ALV display.
I was able to fetch data into internal table as per given logic.
The internal table( gt_out1 ) is as such.
| type | bsad-belnr | bsad-vbeln | bse_clr-belnr_clr | konv-kschl |
|---|---|---|---|---|
| it_field_name | gt_out1-belnr | gt_out1-vbeln | gt_out1-belnr_clr | gt_out1-kschl |
| values | zppu | |||
| values | zppt |
Now based on data in this internal table i have to show the ALV display i.e fill data into a final output internal table. I am stuck here.
The few fields are Posting Date, Currency ,Document Type, Doc Date etc.
The Logic to fetch the fileds is as follows:
For Posting Date:
From the internal table ,pick belnr one by one & pass the same to table bse_clr-belnr, bse_clr-bukrs & bse_clr-bukrs_clr = bse_clr-bukrs
and pick the doc no bse_clr-belnr_clr one by one in the sequence and pass the same to table bsad-bukrs = bse_clr-bukrs & bsad-belnr = bse_clr-belnr_clr and pick posting date bsad-budat.
For currency:
From the internal table ,pick belnr one by one & pass the same to table bse_clr-belnr, bse_clr-bukrs & bse_clr-bukrs_clr = bse_clr-bukrs
and pick the doc no bse_clr-belnr_clr one by one in the sequence and pass the same to table bsad-bukrs = bse_clr-bukrs & bsad-belnr = bse_clr-belnr_clr and pick currency bsad-waers.
For Tax Percentage:
From the internal table ,pick vbeln one by one & pass the same to table vbrk and pass vbrk-vbeln and pick vbrk-knumv. With the doc condition knumv, pass this to konv-knumv = vbrk-knumv and check for condition type konv-kschl = 'ZPPT' or 'ZPPU', if any of one is present, pick percentage konv-kbetr.
There are around 10 more fields with similar logic.
Please help me in writing the code for filling data in the final output table having above fields.
‎2014 Jan 08 8:44 AM
Hi Sanjay,
I'm not sure if I understand your question.
Are you having trouble displaying the contents of your internal table in the ALV?
Or are you having trouble collecting all your data into the internal table that you would like to display in the ALV?
Regards,
Harry
‎2014 Jan 08 8:54 AM
Hi Sanjay,
If the issue is displaying the internal table contents in an ALV, there is quite a simple way to achieve this.
Example:
ITAB is the internal table with all of your data!
Form XXXXX.
data: gr_table type ref to cl_salv_table,
gr_display type ref to cl_salv_display_settings,
gr_functions type ref to cl_salv_functions,
gr_sorts type ref to cl_salv_sorts,
gr_agg type ref to cl_salv_aggregations.
try.
* Create ALV table
cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = itab ).
* Set zebra layout
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
* Display all standard function
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
* Display table
gr_table->display( ).
catch cx_salv_msg.
write: / 'Exception CX_SALV_MSG'.
catch cx_salv_not_found.
write: / 'Exception CX_SALV_NOT_FOUND'.
catch cx_salv_data_error.
write: / 'Exception CX_SALV_DATA_ERROR'.
catch cx_salv_existing.
write: / 'Exception CX_SALV_EXISTING'.
endtry.
ENDFORM.
Regards,
Harry
‎2014 Jan 08 8:47 AM
Hi Sanjay,
Share me your code where you are facing the problem! We can't give you whole logic of your requirement!
By the way better to check the ALV demo programs to understand the algorithm of ALV's
Rg, Kiran
‎2014 Jan 08 3:26 PM
Hi All,
I am having problem in fetching the final data.
I have fetched data into the internal table0 it_out1.
| Billing Document | Accounting Document | Clearing Document Number | Condition Type |
| BSAD | BSAD | bse_clr | KONV |
| 123 | 210 | 123 | z1 |
| 123 | 210 | 456 | z1 |
| 456 | 221 | 789 | z1 |
| 456 | 221 | 913 | z2 |
Now based on this data I need other fields into a final internal table it_out2 as per given logic.
| Billing Document | Accounting Document | Clearing Document Number | Condition Type | Posting Date | Currency | Document Type | Document Date |
| BSAD | BSAD | bse_clr | KONV | BSAD | BSAD | BSAD | BSAD |
| 123 | 210 | 123 | z1 | ||||
| 123 | 210 | 456 | z1 | ||||
| 456 | 221 | 789 | z1 | ||||
| 456 | 221 | 913 | z2 |
So based on it_out1 data(shown in 1st table) is taken into it_out2 and i need to fill the corresponding fields by logic given in my original post.
i need the coding for this part.
‎2014 Jan 09 8:26 AM
Hi Sanjay,
Filling the final internal table should be quite simple to do. Based on what you have done already, I assume you are familiar with the database tables you need to fill the internal tables. I also assume you are familiar with the select statements needed to fill the internal tables.
Thus the last problem you are still facing is moving the data in itab1 into itab_final and selecting the last pieces of data using the original data in itab1.
Here is some pseudo code that should help you move and fill the data in itab_final:
Please make sure you have the same field names in both internal tables. This is needed for move-corresponding to work.
Data: ls_itab1 like line of itab1, *wa or structure of itab
ls_itab_final like line of itab_final. *wa or structure of itab
clear: ls_itab1,
ls_itab_final.
loop at itab1 into ls_itab1.
move-corresponding ls_itab1 to ls_itab_final.
*Select the data from the database based on contents of ls_itab_final!
Select single $fieldname$ from $table$ into ls_itab_final-$fieldname$ where
$fieldname$ = ls_itab_final-$fieldname$ ..........
*When you have filled the remaining fields into the ls_itab_final you append it to the final output table
append ls_itab_final to itab_final.
*clear structure
clear ls_itab_final.
endloop.
Please note that the above pseudo code will not compile, and only serves as a algorithm to move and select the remaining data.
Regards,
Harry
‎2014 Jan 09 8:33 AM
Hi Sanjay,
Your requirement is not clear. Please
1) Take a smaller and detailed example and describe here.
2) Post your code.
3) Debug some standard ALV codes like - BCALV_FULLSCREEN_DEMO in SE38.
BR.