2013 Aug 20 6:20 AM
Hello Experts,
I have a requirement like this. I have to send an alv report as excel attachment through mail.
So basically I have two values in list box......(Overview and Detail). If overview is selected one report is generated and if detail is selected another report is generated.
I am declaring these internal tables for excel creation and sending it as email.
IT_DOCDATA TYPE STANDARD TABLE OF SODOCCHGI1,
IT_PACKLIST TYPE STANDARD TABLE OF SOPCKLSTI1,
IT_ATTACHMENT TYPE STANDARD TABLE OF SOLISTI1,
IT_BODY_MSG TYPE STANDARD TABLE OF SOLISTI1,
IT_RECEIVERS TYPE STANDARD TABLE OF SOMLRECI1.
So my question is can I use the same internal tables and work area for Overview report as well as Detail report. Some times the user will view the overview report and will come to back to see the Detail report. In that case do i have to refresh these internal tables and work areas?
Regards,
Marina.
Hello Experts,
I have a requirement like this. I have to send an alv report as excel attachment through mail.
So basically I have two values in list box......(Overview and Detail). If overview is selected one report is generated and if detail is selected another report is generated.
I am declaring these internal tables for excel creation and sending it as email.
IT_DOCDATA TYPE STANDARD TABLE OF SODOCCHGI1,
IT_PACKLIST TYPE STANDARD TABLE OF SOPCKLSTI1,
IT_ATTACHMENT TYPE STANDARD TABLE OF SOLISTI1,
IT_BODY_MSG TYPE STANDARD TABLE OF SOLISTI1,
IT_RECEIVERS TYPE STANDARD TABLE OF SOMLRECI1.
So my question is can I use the same internal tables and work area for Overview report as well as Detail report. Some times the user will view the overview report and will come to back to see the Detail report. In that case do i have to refresh these internal tables and work areas?
Regards,
Marina.
2013 Aug 20 6:27 AM
Hi Marina Debrova,
If you are using radio button in the selection screen, then you need not refresh your internal table as you need to come back to your selection screen to change from overview and detailed reports, Generally it would be good if you refresh your internal table before populating values into it.
Regards,
Madhumahesh.
2013 Aug 20 6:33 AM
Hi Madhumahesh,
My basic doubt is that can we use the same internal table and work area for both these purposes. (Creating Overview Report and Detail report as I have mentioned in myquestion).
Regards,
Marina.
2013 Aug 20 6:35 AM
Hi,
Are you using radio buttons in the selection screen?
if you are using check box in the selection screen then just clear the work area so that you can use same internal table and work area.
Regards,
Madhumahesh.
2013 Aug 20 6:41 AM
Hi Marina,
You can use the same internal table and work area for Overview as well as Detailed.
Refresh this Internal Table before populating it in both cases.
Clear the work area before using it.
Since you have Overview and Detailed, I am assuming there will be more fields for Detailed hence you can declare the internal table with all fields of Overview as well as Detailed and while using it in both cases use Move-Corresponding and populate it.
Hope this helps else you can browse this forum for more information.
2013 Aug 20 6:46 AM
Hi AN,
Thanks for you reply. For creating the report I have used different internal tables and work areas for overview and detail. But for creating the excel sheet and sending it as mail I am thinking of using the same internal table and work area.
Here are the internal tables and work areas,
IT_DOCDATA TYPE STANDARD TABLE OF SODOCCHGI1,
IT_PACKLIST TYPE STANDARD TABLE OF SOPCKLSTI1,
IT_ATTACHMENT TYPE STANDARD TABLE OF SOLISTI1,
IT_BODY_MSG TYPE STANDARD TABLE OF SOLISTI1,
IT_RECEIVERS TYPE STANDARD TABLE OF SOMLRECI1.
WA_DOCDATA LIKE LINE OF IT_DOCDATA,
WA_PACKLIST LIKE LINE OF IT_PACKLIST,
WA_ATTACHMENT LIKE LINE OF IT_ATTACHMENT,
WA_BODY_MSG LIKE LINE OF IT_BODY_MSG,
WA_RECEIVERS LIKE LINE OF IT_RECEIVERS.
Can I use the same for both (Overview and detail)
Regards,
Marina.
2013 Aug 20 6:49 AM
Hi,
Yes you can use same internal table and work area, But don't forget to clear the work area.
Regards,
Madhumahesh.
2013 Aug 20 7:08 AM
yes you can reuse the Itab and WA. if you don't want to reuse data of Itab and WA then
clear WA and Refresh Itab now your Itab and WA will be empty means no data.
but Don't forget to do a Global Data Deceleration..
BR
Chandra..
2013 Aug 20 7:00 AM
Hi Marina,
You can use the same. But one question when already an internal table has been declared in both cases -Overview and Detailed for report, why don't you use the same internal tables? It would already have data and you can bifurcate it into display and email.
For Overview:
Say internal table ITAB_OVERVIEW will have data,
if display..display it
if email..use for email..
if display and email...use same ITAB_OVERVIEW.
Do the same for Detailed.
You can avoid using extra internal tables that way. Data fetching will be the same in display and email case anyways so use the already existing internal tables.
2013 Aug 20 7:16 AM
Hi AN ,
What if the data fetched for overview and detail is different except for 2 or 3 fields.?
Regards,
Marina.
2013 Aug 20 7:18 AM
Hi,
Just post the code it might be helpful.
Regards,
Madhumahesh.
2013 Aug 20 7:32 AM
then in this case use Dynamic data deceleration or make different different copy.
What if the data fetched for overview and detail is different except for 2 or 3 fields.?
One second.. You are Taking about data or fields type ?
means data in those 2 3 field is different or data-type of them is different.
2013 Aug 20 7:07 AM
Hi Marina,
Clearing the work areas and internal tables works fine. But my strong recommendation is to create dynamic internal table and work area. Please see the below code:
TYPES: BEGIN OF lx_fieldnames,
fieldname TYPE string,
END OF lx_fieldnames.
DATA: lt_fieldnames TYPE TABLE OF lx_fieldnames,
lx_fieldnames TYPE lx_fieldnames.
DATA: lo_tabledescr TYPE REF TO cl_abap_tabledescr,
lo_line TYPE REF TO cl_abap_datadescr,
lo_struct TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: <lt_fields> TYPE ANY TABLE,
<lx_comp> LIKE LINE OF lo_struct->components.\
ASSIGN ltab TO <lt_fields>. "Itab is your internal table
lo_tabledescr ?= cl_abap_typedescr=>describe_by_data( <lt_fields> ).
lo_line = lo_tabledescr->get_table_line_type( ).
IF lo_line->kind = cl_abap_typedescr=>kind_struct.
lo_struct ?= lo_line.
LOOP AT lo_struct->components ASSIGNING <lx_comp>.
lx_fieldnames-fieldname = <lx_comp>-name.
APPEND lx_fieldnames TO lt_fieldnames.
ENDLOOP.
ENDIF
The whole process will get you the coloumns in the report which you want to display. For overview and detailed report the report coloumns will be different right? or in other words fieldcatlog. If you click the overview button the above code will generate the fieldcatalog for the overview report. Pass the same to the fieldcatalog internal table and fill in the main internal table holding the data and pass it to the method or FM to display the ALV.
Similar for detailed report also.
Thank you.
2013 Aug 20 7:09 AM
Hi Marina Debrova,
We can use single internal table and work area for two functions, but you should maintain clear function.
like.
Start-of-selection.
Clear : IT_DOCDATA
IT_PACKLIST
IT_ATTACHMENT
IT_BODY_MSG
IT_RECEIVERS
WA_DOCDATA
WA_PACKLIST
WA_ATTACHMENT
WA_BODY_MSG
WA_RECEIVERS.
2013 Aug 20 7:27 AM
Hi marina,
If you are dynamically display the data according to the user action better to use field-symbols. For your scenario's you can use the same itable for both but before get the value to itable refresh that as well as clear the WA.
Regards,
John.
2013 Aug 20 7:51 AM
Hi marina,
U can use the same internal table for both report just take care of refreshing internal table and clearing work area.
Regards,
Pranali Dnyaneshwar.
2013 Aug 20 7:55 AM
Hi Marina,
It seems like you are new to ABAP and you are asking queries related to basic ABAP.
You have got many suggestions in this post. I think it would be better if you apply whichever suits your requirement. We can only suggest but you have to code as per your requirement.
If you have more doubts you can browse this forum and get help. The best way to learn and code in ABAP is to browse and code.
2013 Aug 22 8:09 AM
HI Marina,
Ideally, you can use the same internal table and work area.
Regards,
Anish Oommen
2013 Aug 22 8:23 AM
Hi Marina,
Yes you can use the same internal table and work area for both reports. Exception is, if you are using check box in the selection screen then just clear the work area so that you can use same internal table and work area. Other than that if you are using push buttons or any radio buttons then you don't need any refresh for you internal table.
Regards,
Krishna.