Skip to Content
0
Former Member
Aug 03, 2008 at 07:17 AM

Inserting data into Ztable

180 Views

Hi frnds,

I am directly Inerting data in Ztable. But i am not able to please do need ful help.

CONSTANTS: mandt TYPE zdealer-mandt VALUE '400',

zbp_sales_org TYPE zdealer-zbp_sales_org VALUE '50000135',

zbp_distr_chann TYPE zdealer-zbp_distr_chann VALUE '10',

ZBP_DIV TYPE zdealer-ZBP_DIV VALUE '01'.

DATA : BEGIN OF gt_upload OCCURS 0,

zbp_so_pa TYPE zdealer-zbp_so_pa,

zbp_terr_id TYPE zdealer-zbp_terr_id,

zcity_class TYPE zdealer-zcity_class,

zbp_tso TYPE zdealer-zbp_tso,

zbp_sale_sup TYPE zdealer-zbp_sale_sup,

zbp_area_man TYPE zdealer-zbp_area_man,

zbp_regio_man TYPE zdealer-zbp_regio_man,

zbp_div_man TYPE zdealer-zbp_div_man,

zbp_mkt_man TYPE zdealer-zbp_mkt_man,

zbp_gen_man TYPE zdealer-zbp_gen_man,

zbp_mkt_spoc TYPE zdealer-zbp_mkt_spoc,

zbp_prod_spoc TYPE zdealer-zbp_prod_spoc,

zbp_plant_spoc TYPE zdealer-zbp_plant_spoc,

zbp_acc_spoc TYPE zdealer-zbp_acc_spoc,

zbp_comm_spoc TYPE zdealer-zbp_comm_spoc,

zbp_del_spoc TYPE zdealer-zbp_del_spoc,

zbp_techno TYPE zdealer-zbp_techno,

zbp_qsg_spoc TYPE zdealer-zbp_qsg_spoc,

zbp_sales_off TYPE zdealer-zbp_sales_off,

ZBP_SOURCE_SPOC TYPE zdealer-ZBP_SOURCE_SPOC, "+

ZBP_SALES_UNIT TYPE zdealer-ZBP_SALES_UNIT, "+

ZBP_APHS_BM TYPE zdealer-ZBP_APHS_BM, "+

ZAP_HL_BM TYPE zdealer-ZAP_HL_BM, "+

ZBP_AP_HL_MAN TYPE zdealer-ZBP_AP_HL_MAN, "+

ZBP_AP_SUPER TYPE zdealer-ZBP_AP_SUPER, "+

END OF gt_upload.

DATA zdealer_wa TYPE zdealer.

DATA : p_file TYPE string.

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

  • SELECTION SCREEN

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

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

PARAMETERS : p_fname1(100) TYPE c OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK b1.

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

  • AT SELECTION SCREEN

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

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname1.

PERFORM f4_filename USING p_fname1.

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

  • START OF SELECTION

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

START-OF-SELECTION.

PERFORM file_upload.

LOOP AT gt_upload.

CLEAR zdealer_wa.

zdealer_wa-mandt = mandt.

zdealer_wa-zbp_so_pa = gt_upload-zbp_so_pa.

zdealer_wa-zcity_class = gt_upload-zcity_class.

zdealer_wa-zbp_tso = gt_upload-zbp_tso .

zdealer_wa-zbp_sale_sup = gt_upload-zbp_sale_sup.

zdealer_wa-zbp_area_man = gt_upload-zbp_area_man.

zdealer_wa-zbp_regio_man = gt_upload-zbp_regio_man.

zdealer_wa-zbp_div_man = gt_upload-zbp_div_man .

zdealer_wa-zbp_mkt_man = gt_upload-zbp_mkt_man .

zdealer_wa-zbp_gen_man = gt_upload-zbp_gen_man .

zdealer_wa-zbp_mkt_spoc = gt_upload-zbp_mkt_spoc.

zdealer_wa-zbp_prod_spoc = gt_upload-zbp_prod_spoc.

zdealer_wa-zbp_plant_spoc = gt_upload-zbp_plant_spoc.

zdealer_wa-zbp_acc_spoc = gt_upload-zbp_acc_spoc .

zdealer_wa-zbp_comm_spoc = gt_upload-zbp_comm_spoc .

zdealer_wa-zbp_del_spoc = gt_upload-zbp_del_spoc .

zdealer_wa-zbp_techno = gt_upload-zbp_techno .

zdealer_wa-zbp_qsg_spoc = gt_upload-zbp_qsg_spoc .

zdealer_wa-zbp_sales_org = zbp_sales_org .

zdealer_wa-zbp_distr_chann = zbp_distr_chann.

zdealer_wa-zbp_div = zbp_div .

zdealer_wa-zbp_sales_off = gt_upload-zbp_sales_off .

zdealer_wa-ZBP_SOURCE_SPOC = gt_upload-ZBP_SOURCE_SPOC.

zdealer_wa-ZBP_SALES_UNIT = gt_upload-ZBP_SALES_UNIT.

zdealer_wa-ZBP_APHS_BM = gt_upload-ZBP_APHS_BM.

zdealer_wa-ZAP_HL_BM = gt_upload-ZAP_HL_BM.

zdealer_wa-ZBP_AP_HL_MAN = gt_upload-ZBP_AP_HL_MAN.

zdealer_wa-ZBP_AP_SUPER = gt_upload-ZBP_AP_SUPER.

INSERT into zdealer values zdealer_wa.

*modify zdealer from zdealer_wa.

CLEAR gt_upload.

ENDLOOP.

COMMIT WORK.

&----


*& Form f4_filename

&----


FORM f4_filename USING file.

DATA : l_it_filetable TYPE filetable,

wa_filetable LIKE LINE OF l_it_filetable,

l_rc TYPE i.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

CHANGING

file_table = l_it_filetable

rc = l_rc

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

OTHERS = 5.

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 sy-subrc = 0 AND l_rc = 1.

READ TABLE l_it_filetable INTO wa_filetable INDEX 1.

file = wa_filetable-filename.

ENDIF.

ENDFORM. " f4_filename

&----


*& Form FILE_UPLOAD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM file_upload .

CLEAR p_file.

MOVE : p_fname1 TO p_file.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = p_file

has_field_separator = 'X'

CHANGING

data_tab = gt_upload[]

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

not_supported_by_gui = 17

error_no_gui = 18

OTHERS = 19.

IF sy-subrc <> 0.

MESSAGE i039(zaba)

WITH 'Error in Upload. Error code --> ' sy-subrc.

STOP.

ENDIF.

ENDFORM. " FILE_UPLOAD

Regards,

Mehul.