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

ABAP - Upload method based on user selection

Former Member
1,549

Hello All,

I have a program which uploads excel data to database table.

Now I would like to split the program:

based on User decision whether it gets uploaded to internal table only or directly to database.

Can you please suggest the way how I could process this? I tried with radiobutton, I could not manage, though might be a solution.

So far I have written below:

REPORT ZBB_TEST01.



TYPE-POOLS truxs.


TABLES : wcamb.



PARAMETER p_file TYPE rlgrap-filename DEFAULT 'C:\Users\......XLSX'.


TYPES:
BEGIN OF t_tab,
userid TYPE wcamb-userid,
iwerk TYPE wcamb-iwerk,
worklist_variant type wcamb-worklist_variant,
END OF t_tab.


DATA :
t_upload TYPE STANDARD TABLE OF t_tab,
wa_upload TYPE t_tab,
it_type TYPE truxs_t_text_data.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.


CALL FUNCTION 'F4_FILENAME'
EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
field_name = 'P_FILE'
IMPORTING
file_name = p_file.


START-OF-SELECTION.
* Uploading the data in the file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = t_upload[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
END-OF-SELECTION.


* Uploading the data into the database table
LOOP AT T_UPLOAD INTO WA_UPLOAD.
wcamb-userid = WA_UPLOAD-userid.
wcamb-iwerk = WA_UPLOAD-iwerk.
Wcamb-worklist_variant = WA_UPLOAD-worklist_variant. MODIFY wcamb.

ENDLOOP.

Thanks a lot.

Brg

5 REPLIES 5
Read only

former_member751964
Participant
0 Likes
1,437

Welcome to the SAP Community! We wanted to give you the opportunity to take the tutorial to get started in SAP Community: https://developers.sap.com/tutorials/community-qa.html, as it provides tips for preparing questions that draw responses from our members. Additionally, by adding a picture to your profile you encourage readers to respond to your question. Learn more about your profile here: https://developers.sap.com/tutorials/community-profile.html

Read only

FredericGirod
Active Contributor
1,437

what is the problem with radiobutton ?

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,437

Please edit your question, select your code and press the "CODE" button to make it correctly colorized/indented, so that it's easier for us to analyze it. Thank you.

Read only

irfanjazz1
Participant
0 Likes
1,437

put radiobutton with condition.

if rb1.
excel to internal table.
elseif rb2.
excel to db table.
endif.
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,437

You wrote 'I tried with radiobutton[S],' but there are no radiobutton in your code?

  • Add two radiobuttons in same group (one for itab one for table, itab by default?)
    (or a 'test' checkbox)
  • Check which rariobutton is checked and either display data (ALV) or update the database (z) table