report zff67_upload.
types: begin of ty_upload,
valut type char10,
kwbtr type string,
chect_kf type string,
end of ty_upload.
data: it_upload type table of ty_upload,
wa_upload type ty_upload.
types: begin of ty_upload1,
bankl type string,
bankn type string,
waers type string,
aznum type string,
azdat type string,
ssald type string,
esald type string,
budtm type string,
vgman type string,
end of ty_upload1.
data: it_upload1 type table of ty_upload1,
wa_upload1 type ty_upload1.
data : w_fname type rlgrap-filename.
data : bdcdata like bdcdata occurs 0 with header line,
messtab like bdcmsgcoll occurs 0 with header line,
it_raw type truxs_t_text_data,
v_text type c length 200,
chk type c.
data: gv_string type string,
gv_row type i,
gv_row_str type string.
data: it_intrn type standard table of alsmex_tabline.
data: it_intrn1 type standard table of alsmex_tabline.
data: is_intrn type alsmex_tabline.
data: flag type i value 0,
c_bcol type i value 1 , "START COLUMN
c_brow type i value 4 , "START ROW
c_ecol type i value 200 , "Ending column
c_erow type i value 40000 . "ENDING ROW
selection-screen : begin of block b2 with frame title text-001 .
parameters:p_path type rlgrap-filename.". OBLIGATORY.
parameters:mode type ctu_params-dismode default 'E'.
selection-screen : end of block b2 .
parameters ptype type febmka-wvar_art DEFAULT 3.
at selection-screen on value-request for p_path.
call function 'F4_FILENAME'
exporting
field_name = 'PATH'
importing
file_name = p_path.
if not p_path is initial.
w_fname = p_path.
endif.
start-of-selection.
perform sub_uploadexcel.
form sub_uploadexcel .
if not w_fname is initial.
data : wl_index type i.
field-symbols <fs>.
refresh: it_intrn,it_upload,it_intrn1,it_upload1.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = w_fname
i_begin_col = c_bcol
i_begin_row = c_brow
i_end_col = c_ecol
i_end_row = c_erow
tables
intern = it_intrn.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = w_fname
i_begin_col = 01
i_begin_row = 02
i_end_col = 200
i_end_row = 03
tables
intern = it_intrn1.
loop at it_intrn1 into is_intrn.
move is_intrn-col to wl_index.
*--- Assigning the each record to an internal table row
assign component wl_index of structure wa_upload1 to <fs>.
if sy-subrc = 0.
*--- Asigning the field value to a field symbol
condense is_intrn-value.
move is_intrn-value to <fs>.
endif.
at end of row.
append wa_upload1 to it_upload1.
clear wa_upload1.
endat.
endloop.
loop at it_intrn into is_intrn.
move is_intrn-col to wl_index.
*--- Assigning the each record to an internal table row
assign component wl_index of structure wa_upload to <fs>.
if sy-subrc = 0.
*--- Asigning the field value to a field symbol
condense is_intrn-value.
move is_intrn-value to <fs>.
endif.
at end of row.
append wa_upload to it_upload.
clear wa_upload.
endat.
endloop.
clear : p_path, w_fname.
else.
message i002(sy) with 'Select valid file'.
endif.
if it_upload[] is not initial.
loop at it_upload into wa_upload.
if flag = '0'.
read table it_upload1 into wa_upload1 index 1.
condense:wa_upload1-bankl, wa_upload1-bankn,wa_upload1-aznum.
perform bdc_dynpro using 'SAPMF40K' '0102'.
perform bdc_field using 'BDC_OKCODE'
'/EVORG'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BANKL'.
perform bdc_dynpro using 'SAPMF40K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-WVAR_ART'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'FEBMKA-FDIS_SEL'
'X'.
perform bdc_field using 'FEBMKA-VARI_START'
'CS01'.
perform bdc_field using 'FEBMKA-DEBI_MID'
'D'.
perform bdc_field using 'FEBMKA-KRED_MID'
'K'.
perform bdc_field using 'FEBMKA-WVAR_ART'
ptype ." '3'.
perform bdc_field using 'FEBMKA-BUCH_VAL'
'X'.
perform bdc_dynpro using 'SAPMF40K' '0102'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BUDTM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'FEBMKA-BANKL'
wa_upload1-bankl. " '911020029681621'.
perform bdc_field using 'FEBMKA-BANKN'
wa_upload1-bankn." '911020029681621'.
perform bdc_field using 'FEBMKA-WAERS'
wa_upload1-waers." 'INR'.
perform bdc_field using 'FEBMKA-AZNUM'
wa_upload1-aznum." '11'.
perform bdc_field using 'FEBMKA-AZDAT'
wa_upload1-azdat." '02.01.2017'.
perform bdc_field using 'FEBMKA-SSALD'
wa_upload1-ssald." ' 10'.
perform bdc_field using 'FEBMKA-ESALD'
wa_upload1-esald." ' 10'.
perform bdc_field using 'FEBMKA-BUDTM'
wa_upload1-budtm."." '11.01.2017'.
if ptype = '3'.
perform bdc_field using 'FEBMKA-JNAME'
sy-uname. " 'SLV111986'.
endif.
flag = 1.
perform bdc_dynpro using 'SAPMF40K' '8004'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-VGMAN(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ZINS'.
perform bdc_dynpro using 'SAPMF40K' '8004'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKK-ZUONR_KF(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ZINS'.
find '-' in wa_upload-kwbtr .
if sy-subrc = 0.
perform bdc_field using 'FEBMKA-VGMAN(01)'
'C200'.
else.
perform bdc_field using 'FEBMKA-VGMAN(01)'
'C100'.
endif.
perform bdc_field using 'FEBEP-VALUT(01)'
wa_upload-valut." '01.01.2017'.
condense: wa_upload-kwbtr.
perform bdc_field using 'FEBMKA-KWBTR(01)'
wa_upload-kwbtr." ' 10'.
perform bdc_field using 'FEBMKK-CHECT_KF(01)'
wa_upload-chect_kf." 'City'.
perform bdc_field using 'FEBMKK-ZUONR_KF(01)'
wa_upload-chect_kf."
perform bdc_dynpro using 'SAPMF40K' '8004'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKK-ZUONR_KF(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ZINS'.
else.
find '-' in wa_upload-kwbtr .
if sy-subrc = 0.
perform bdc_field using 'FEBMKA-VGMAN(01)'
'C200'.
else.
perform bdc_field using 'FEBMKA-VGMAN(01)'
'C100'.
endif.
perform bdc_field using 'FEBEP-VALUT(01)'
wa_upload-valut." '01.01.2017'.
condense: wa_upload-kwbtr.
perform bdc_field using 'FEBMKA-KWBTR(01)'
wa_upload-kwbtr." ' 10'.
perform bdc_field using 'FEBMKK-CHECT_KF(01)'
wa_upload-chect_kf." 'City'.
perform bdc_field using 'FEBMKK-ZUONR_KF(01)'
wa_upload-chect_kf."
perform bdc_dynpro using 'SAPMF40K' '8004'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKK-ZUONR_KF(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ZINS'.
endif.
clear:wa_upload.
endloop.
perform bdc_dynpro using 'SAPMF40K' '8004'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKK-CHECT_KF(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_dynpro using 'SAPMF40K' '0102'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BANKL'.
perform bdc_field using 'BDC_OKCODE'
'=BUCH'.
perform bdc_field using 'FEBMKA-BANKL'
wa_upload1-bankl. " '911020029681621'.
perform bdc_field using 'FEBMKA-BANKN'
wa_upload1-bankn. " '911020029681621'.
perform bdc_field using 'FEBMKA-WAERS'
wa_upload1-waers. " 'INR'.
perform bdc_field using 'FEBMKA-AZNUM'
wa_upload1-aznum. " '11'.
perform bdc_field using 'FEBMKA-AZDAT'
wa_upload1-azdat. "'02.01.2017'.
perform bdc_field using 'FEBMKA-SSALD'
wa_upload1-ssald. " ' 10,00'.
perform bdc_field using 'FEBMKA-ESALD'
wa_upload1-esald. " ' 10,00'.
perform bdc_field using 'FEBMKA-BUDTM'
wa_upload1-budtm. " '11.01.2017'.
if ptype = '3'.
perform bdc_field using 'FEBMKA-JNAME'
sy-uname. " 'SLV111986'.
endif.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_OKCODE'
'=&F03'.
perform bdc_dynpro using 'SAPMF40K' '0102'.
perform bdc_field using 'BDC_OKCODE'
'/EABBR'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BANKL'.
perform bdc_transaction using 'FF67'.
* clear: wa_upload.
*
*
* endloop.
uline.
else.
message 'No data found from this file path' type 'E'.
endif.
endform.
form bdc_dynpro using program dynpro.
clear bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata.
endform. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
if fval <> ' '.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
endif.
endform. "BDC_FIELD
form bdc_transaction using tcode.
data : ctu_params type ctu_params.
ctu_params-dismode = mode ."'N'.
ctu_params-updmode = 'S'.
ctu_params-defsize = 'X'.
call transaction tcode using bdcdata
options from ctu_params
messages into messtab.
clear: bdcdata, bdcdata[].
commit work.
gv_row = gv_row + 1.
gv_row_str = gv_row.
if gv_row = 1.
write: / sy-vline,2 'Row ID', 10 sy-vline,12 'Error',19 sy-vline,21 'Bank Key' ,42 sy-vline,44 'Message'.
uline.
endif.
if messtab[] is not initial.
loop at messtab.
message id messtab-msgid
type messtab-msgtyp
number messtab-msgnr
into gv_string
with messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
write: / sy-vline,2 gv_row_str, 10 sy-vline,12 messtab-msgtyp,19 sy-vline,21 wa_upload1-bankl ,42 sy-vline,44 gv_string.
endloop.
else.
write: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 wa_upload1-bankl ,42 sy-vline,44 'Success'.
endif.
endform. " BDC_TRANSACTION