2008 Dec 30 6:25 AM
My requirement is po upload using bapi.in that we hav to provide both presentation server and application server option in the selection screen.
If the presentation server option is selected then user can select the file type like Text or Excel.
File will contain field names in the first line of the fileu2026u2026for this we hav to declare one work area w1(each field 40 char) and we hav to move the header which hav field names to this work area.
The actual data starts from second line of the file.so for this we hav to declare another work area w2 with actual length and we hav to move the data from second line to this work area(w2).
Moving the data is based on the header i.e
If w1-header = indicator .
W2-poind = file-poind.
If w1-header = company code
W2-bukrs = file-bukrs.
So that the columns can be interchanged in the file and program can be executedu2026u2026
My requirement is po upload using bapi.in that we hav to provide both presentation server and application server option in the selection screen.
If the presentation server option is selected then user can select the file type like Text or Excel.
File will contain field names in the first line of the fileu2026u2026for this we hav to declare one work area w1(each field 40 char) and we hav to move the header which hav field names to this work area.
The actual data starts from second line of the file.so for this we hav to declare another work area w2 with actual length and we hav to move the data from second line to this work area(w2).
Moving the data is based on the header i.e
If w1-header = indicator .
W2-poind = file-poind.
If w1-header = company code
W2-bukrs = file-bukrs.
So that the columns can be interchanged in the file and program can be executedu2026u2026
2008 Dec 30 6:37 AM
hi,
Use this code to upload data from Excel to internal table...
DATA l_count TYPE sy-tabix.
CONSTANTS: lc_begin_col TYPE i VALUE '1',
lc_begin_row TYPE i VALUE '2',
lc_end_col TYPE i VALUE '2',
lc_end_row TYPE i VALUE '3000'.
* Begin of CALK912848 - Carlos Werberich - 16Sep08
CLEAR p_i_excel_data. REFRESH p_i_excel_data.
* End of CALK912848 - Carlos Werberich - 16Sep08
* Function module to read excel file and convert it into internal table
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_p_file
i_begin_col = lc_begin_col
i_begin_row = lc_begin_row
i_end_col = lc_end_col
i_end_row = lc_end_row
TABLES
intern = i_data
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
* Error in file upload
IF sy-subrc NE 0 .
MESSAGE text-006 TYPE 'E'.
EXIT.
ENDIF.
IF i_data[] IS INITIAL .
MESSAGE text-007 TYPE 'E'.
EXIT.
ELSE.
SORT i_data BY row col .
* Loop to fill data in Internal Table
LOOP AT i_data .
MOVE i_data-col TO l_count .
ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO .
AT END OF row .
* Append data into internal table
APPEND p_i_excel_data.
CLEAR p_i_excel_data.
ENDAT .
ENDLOOP .
ENDIF
2008 Dec 30 6:41 AM
hi avinash,
for excel upload i shuld use only TEXT_CONVERT_XLS_TO_SAP function module.