Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

uploading data to EXCEL

Former Member
0 Likes
978

hello,

We currently have a process where the users update a excel spreadsheet and call a ABAP pgm to upload the spreadsheet data to SAP for processing in FB01. The front-end screen is where the user enters the path and filename for the file. this is usually on their C drive. I would like to know if there a SAP process that will let me enter data similar to an excel spreadsheet or copy data from a excel spreadsheet to a form in SAP? I could then use this form for my processing. This way when I need to update the form and the programs, the two would get transported together and eliminate the problem of the form not matching the program.

thanks you in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
888

Hi Timothy,

Iam sending the code code to upload data from excel sheet to a ztable table.All you have to do is browse the location of file which in your case is c drive and then execute. I think all you have to do is create an unternal table with the fields similiar to FB01 and loop the internal table and update the corresponding table.

Hope this helps.

******************************************************

  • Program to upload data from excel sheet to z340b_md

  • Code written by Venkat Goli s

*******************************************************

REPORT Z340BMD_DATA no standard page heading line-size 255 .

Tables : zabc.

Data : Begin of t_upload occurs 0,

ZZPHYACT like zabc-ZZPHYACT, " zzphyact - physician id

ZZLNAME like zabc-ZZLNAME, " zzlname - last name

ZZFNAME like zabc-ZZFNAME, " zzfname - first name

end of t_upload.

Data : i_itab_sheet like alsmex_tabline occurs 0 with

header line.

data: it_dup like t_upload occurs 0 with header line.

  • selection-screen

selection-screen: begin of block blk with frame title text-001.

selection-screen : skip 1.

parameters : p_file like rlgrap-filename.

selection-screen : skip 1.

selection-screen : end of block blk.

at selection-screen on value-request for p_file.

    • F4 Value for File

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

STATIC = 'X'

  • MASK = ' '

CHANGING

FILE_NAME = p_file

EXCEPTIONS

MASK_TOO_LONG = 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.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = p_file

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 3

I_END_ROW = 12507

TABLES

INTERN = i_itab_sheet

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Reading data in to internal table t_upload

loop at i_itab_sheet.

If i_itab_sheet-col = 1.

t_upload-ZZPHYACT = i_itab_sheet-value.

elseIF i_itab_sheet-col = 2.

t_upload-ZZLNAME = i_itab_sheet-value.

else.

t_upload-ZZFNAME = i_itab_sheet-value.

append t_upload.

endif.

ENDLOOP.

  • sorting the records

sort t_upload by zzphyact zzlname zzfname.

  • To check for the duplicate records

loop at t_upload.

If it_dup EQ t_upload.

write : / ' The Following Records Exists More Than Once In The File'.

skip 2.

write : / it_dup.

endif.

it_dup = t_upload.

endloop.

    • Deleting the duplicate records

DELETE ADJACENT DUPLICATES FROM t_upload COMPARING zzphyact zzlname

zzfname.

      • Updating the z340b_md table

modify z340b_md from table t_upload.

hello,

We currently have a process where the users update a excel spreadsheet and call a ABAP pgm to upload the spreadsheet data to SAP for processing in FB01. The front-end screen is where the user enters the path and filename for the file. this is usually on their C drive. I would like to know if there a SAP process that will let me enter data similar to an excel spreadsheet or copy data from a excel spreadsheet to a form in SAP? I could then use this form for my processing. This way when I need to update the form and the programs, the two would get transported together and eliminate the problem of the form not matching the program.

thanks you in advance

3 REPLIES 3
Read only

Former Member
0 Likes
888

hi Hixson

Have a look at this Link

http://www.sapdevelopment.co.uk/file/file_upexcelalt1.htm

Regards,

Santosh

Read only

Former Member
0 Likes
888

Hi Timothy

I am not aware if there is any form similar to Excel.

But you can upload excel to internal table using function

ALSM_EXCEL_TO_INTERNAL_TABLE

Regards

Naresh

Read only

Former Member
0 Likes
889

Hi Timothy,

Iam sending the code code to upload data from excel sheet to a ztable table.All you have to do is browse the location of file which in your case is c drive and then execute. I think all you have to do is create an unternal table with the fields similiar to FB01 and loop the internal table and update the corresponding table.

Hope this helps.

******************************************************

  • Program to upload data from excel sheet to z340b_md

  • Code written by Venkat Goli s

*******************************************************

REPORT Z340BMD_DATA no standard page heading line-size 255 .

Tables : zabc.

Data : Begin of t_upload occurs 0,

ZZPHYACT like zabc-ZZPHYACT, " zzphyact - physician id

ZZLNAME like zabc-ZZLNAME, " zzlname - last name

ZZFNAME like zabc-ZZFNAME, " zzfname - first name

end of t_upload.

Data : i_itab_sheet like alsmex_tabline occurs 0 with

header line.

data: it_dup like t_upload occurs 0 with header line.

  • selection-screen

selection-screen: begin of block blk with frame title text-001.

selection-screen : skip 1.

parameters : p_file like rlgrap-filename.

selection-screen : skip 1.

selection-screen : end of block blk.

at selection-screen on value-request for p_file.

    • F4 Value for File

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

STATIC = 'X'

  • MASK = ' '

CHANGING

FILE_NAME = p_file

EXCEPTIONS

MASK_TOO_LONG = 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.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = p_file

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 3

I_END_ROW = 12507

TABLES

INTERN = i_itab_sheet

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Reading data in to internal table t_upload

loop at i_itab_sheet.

If i_itab_sheet-col = 1.

t_upload-ZZPHYACT = i_itab_sheet-value.

elseIF i_itab_sheet-col = 2.

t_upload-ZZLNAME = i_itab_sheet-value.

else.

t_upload-ZZFNAME = i_itab_sheet-value.

append t_upload.

endif.

ENDLOOP.

  • sorting the records

sort t_upload by zzphyact zzlname zzfname.

  • To check for the duplicate records

loop at t_upload.

If it_dup EQ t_upload.

write : / ' The Following Records Exists More Than Once In The File'.

skip 2.

write : / it_dup.

endif.

it_dup = t_upload.

endloop.

    • Deleting the duplicate records

DELETE ADJACENT DUPLICATES FROM t_upload COMPARING zzphyact zzlname

zzfname.

      • Updating the z340b_md table

modify z340b_md from table t_upload.