Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
shrikantpatil
Explorer
The ABAPers journey is incomplete without where we need to process Excel file data for further processing. In my experience, it is mostly for BAPI development i.e. getting the data from an Excel file and converting it to a suitable form.

Earlier I was using Loop, Endloop statements, and CONVERSION_EXIT_ALPHA_INPUT function module for the same. It was long and messy coding.

And now using ABAP7.4 using VALUE & FOR statements code started looking literally beautiful.

Below is a code snippet using ABAP 7.4
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = gt_file
i_filename = p_file
TABLES
i_tab_converted_data = gt_data
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

IF gt_data[] IS NOT INITIAL.

DATA(gt_final) = VALUE tt_final( FOR ls_final IN gt_data ( bukrs = ls_final-bukrs
ebeln = |{ ls_final-ebeln ALPHA = IN }|
bsart = ls_final-bsart
ernam = ls_final-ernam
aedat = ls_final-aedat
lifnr = |{ ls_final-lifnr ALPHA = IN }|
) ).
ENDIF.

 

 

The data declaration as per below.
TYPES: BEGIN OF gty_final,
bukrs TYPE bukrs,
ebeln TYPE ebeln,
bsart TYPE esart,
ernam TYPE ernam,
aedat TYPE erdat,
lifnr TYPE lifnr,
END OF gty_final,
tt_final TYPE STANDARD TABLE OF gty_final WITH DEFAULT KEY.

DATA: gt_file TYPE truxs_t_text_data,
gt_data TYPE STANDARD TABLE OF gty_final.

 

Actually, I am still learning ABAP 7.4 and OOPs concepts while coding.

Your inputs are welcome & if you have any blogs to add more, please feel free to comment.

Also, FYI this is my first blog, so if you find anything unusual please say it so I can improve myself.

 

Thanks,

Shrikant Patil

 
2 Comments