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

QS21 upload using BAPI--> BAPI_QPGR_SAVEREPLICA

Former Member
0 Likes
816

I am using BAPI --> BAPI_QPGR_SAVEREPLICA to upload data into QS21 : Edit catalog.

The data is getting updated but I am not getting any type of return code as I want to capture message ..

Can anybody suggest me with coding..

thanks

naresh

1 REPLY 1
Read only

Former Member
0 Likes
481

Hi,

Data : t_return like bapiret2

occurs 0 with header line.

call function 'BAPI_QPGR_SAVEREPLICA'

exporting

i_code_group = s_i_code_group

tables

code_grp_shorttexttab = t_code_grp_shorttexttab

code_grp_longtexttab = t_code_grp_longtexttab

codes_of_code_grp = t_codes_of_code_grp

code_shorttexttab = t_code_shorttexttab

code_longtexttab = t_code_longtexttab

return = t_return

extension1 = t_extension1

exceptions

others = 1

.

t_return here u get all the message (Success and Error Message)

otherwise Use this program

TYPES:BEGIN OF ty_src,

cat_type LIKE bapiqpgr_qpgr-cat_type,

code_group LIKE bapiqpgr_qpgr-code_group,

short_text LIKE bapiqpgr_qpgt-short_text,

code LIKE bapiqpgr_qpcd-code,

st LIKE bapiqpgr_qpct-short_text,

END OF ty_src.

DATA int_src TYPE TABLE OF ty_src.

DATA wa_src TYPE ty_src.

DATA: ws_filename TYPE string.

DATA: gt_bapiqpgr_qpgr TYPE bapiqpgr_qpgr OCCURS 0 WITH HEADER LINE,

gt_bapiqpgr_qpgt TYPE bapiqpgr_qpgt OCCURS 0 WITH HEADER LINE,

gt_bapiqpgr_qpcd TYPE bapiqpgr_qpcd OCCURS 0 WITH HEADER LINE,

gt_bapiqpgr_qpct TYPE bapiqpgr_qpct OCCURS 0 WITH HEADER LINE,

gt_bapiret2 TYPE bapiret2 OCCURS 0 WITH HEADER LINE.

CONSTANTS:

lit_fty(10) TYPE c VALUE 'ASC',

lit_sep(1) TYPE c VALUE 'X'.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.

PARAMETERS: p_fn LIKE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK a1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fn.

PERFORM get_filename USING 'P_FN'

CHANGING p_fn.

START-OF-SELECTION.

PERFORM upload_file.

LOOP AT int_src INTO wa_src.

CLEAR:gt_bapiqpgr_qpgr,gt_bapiqpgr_qpgt.

CLEAR:gt_bapiqpgr_qpcd,gt_bapiqpgr_qpct.

gt_bapiqpgr_qpgr-function = '004'.

gt_bapiqpgr_qpgr-cat_type = wa_src-cat_type.

gt_bapiqpgr_qpgr-code_group = wa_src-code_group.

gt_bapiqpgr_qpgr-status = '2'.

APPEND gt_bapiqpgr_qpgr.

gt_bapiqpgr_qpgt-langu = 'EN'.

gt_bapiqpgr_qpgt-short_text = wa_src-short_text.

APPEND gt_bapiqpgr_qpgt.

gt_bapiqpgr_qpcd-code = wa_src-code.

APPEND gt_bapiqpgr_qpcd.

gt_bapiqpgr_qpct-code = wa_src-code.

gt_bapiqpgr_qpct-langu = 'EN'.

gt_bapiqpgr_qpct-short_text = wa_src-st.

APPEND gt_bapiqpgr_qpct.

CALL FUNCTION 'BAPI_QPGR_SAVEREPLICA'

EXPORTING

i_code_group = gt_bapiqpgr_qpgr

TABLES

code_grp_shorttexttab = gt_bapiqpgr_qpgt

codes_of_code_grp = gt_bapiqpgr_qpcd

code_shorttexttab = gt_bapiqpgr_qpct

return = gt_bapiret2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

return = gt_bapiret2.

ENDLOOP.

*&----


*& Form upload_file

*&----


FORM upload_file .

ws_filename = p_fn.

*Upload input file content

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = ws_filename

filetype = lit_fty

has_field_separator = lit_sep

TABLES

data_tab = int_src

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

ENDFORM. " upload_file

*&----


*& Form get_filename

*&----


FORM get_filename USING value(p_file)

CHANGING p_fn.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

field_name = p_file

IMPORTING

file_name = p_fn.

ENDFORM. " get_filename

Reward if useful......

Thanks,

Durai.V