Report z_fi_expe_trvl .
include zfiexpltop.
include zfiexpltsel.
include zfiexpltpro.
include zfiexpltprt.
initialization.
perform bint.
start-of-selection.
perform fill_data.
* *******************************************************************************
*&---------------------------------------------------------------------*
*& Include ZFIEXPLTOP
*&---------------------------------------------------------------------*
tables: bkpf,lfa1.
type-pools : slis,icon,vimty,abap,truxs.
include <icon>.
include <symbol>.
*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
data: bdcdata like bdcdata occurs 0 with header line.
* messages of call transaction
data: messtab like bdcmsgcoll occurs 0 with header line.
* error session opened (' ' or 'X')
data: begin of it_messtab occurs 0 .
include structure bdcmsgcoll.
data: l_mstring(480) type c.
data: end of it_messtab.
data: e_group_opened.
* message texts
tables: t100.
types : begin of ty_dat,
col_01(025),
col_02(025),
col_03(025),
col_04(025),
col_05(025),
col_06(025),
col_07(025),
col_08(025),
col_09(025),
col_10(025),
col_11(025),
col_12(025),
col_13(025),
col_14(025),
col_15(025),
col_16(025),
col_17(025),
col_18(025),
col_19(025),
line type string,
trf_light(001),
status(060),
end of ty_dat,
begin of ty_data,
col_01(025),
col_02(025),
col_03(025),
col_04(025),
col_05(025),
col_06(025),
col_07(025),
col_08(025),
col_09(025),
col_10(025),
col_11(025),
col_12(025),
col_13(025),
col_14(025),
col_15(025), "Newbs
col_16(025),
col_17(025),
col_18(025),
col_19(025),
trf_light(001),
status(060),
end of ty_data,
begin of ty_date,
col_13(025), "Line
col_01(025),
col_02(025),
col_03(025),
col_04(025),
col_05(025),
col_06(025),
col_07(025),
col_08(025),
col_09(025),
col_10(025),
col_11(025),
col_12(025),
* Col_13(025), "Line
col_14(025), "Form_No
col_15(025),
col_16(025),
col_17(025),
col_18(025),
col_19(025),
end of ty_date,
begin of ty_dats,
* BLDAT(025),
frm_no(025),
bldat(025),
* BLART(025),
bukrs(025),
budat(025),
waers(025),
xblnr(025),
bktxt(025),
newko(025),
hkont(010),
wrbtr(025),
bupla(025),
gsber(025),
zuonr(025),
sgtxt(050),
xref1(025),
hbkid(025),
bvtyp(025),
xref2(025),
xref3(020),
kostl(025),
matnr(025),
belnr(025),
newbs(02),
gjahr(011),
line type string,
trf_light(001),
status(060),
end of ty_dats,
begin of ty_fb01,
frm_no(016),
bldat(010),
blart(005),
budat(010),
waers(005),
xblnr(016),
bktxt(025),
newbs(005),
newko(017),
hkont(010),
wrbtr(016),
bupla(005),
gsber(005),
zuonr(018),
sgtxt(050),
bvtyp(004),
xref1(012),
hbkid(005),
xref2(012),
xref3(020),
kostl(010),
matnr(018),
belnr(011),
bukrs(004),
gjahr(011),
trf_light(001),
status(060),
end of ty_fb01.
data : it_fb01 type table of ty_fb01,
wa_fb01 type ty_fb01,
it_fb02 type table of ty_fb01,
wa_fb02 type ty_fb01,
it_data type table of ty_dats with header line,
wa_data type ty_dats,
it_dat1 type table of ty_data with header line,
wa_dat1 type ty_data,
it_dat2 type table of ty_data with header line,
wa_dat2 type ty_data,
it_dat type table of ty_dat with header line,
wa_dat type ty_dat,
it_date type table of ty_date with header line,
wa_date type ty_date.
data : lv_fname type string,
table_n type i,
g_line type string,
dg_status(60).
data: t_fldcat type slis_t_fieldcat_alv,
s_fldcat type slis_fieldcat_alv,
t_sort type slis_t_sortinfo_alv," WITH HEADER LINE,
t_fldcat2 type slis_t_fieldcat_alv,
s_fldcat2 type slis_fieldcat_alv,
t_sort2 type slis_t_sortinfo_alv," WITH HEADER LINE,
wa_sortinfo type slis_sortinfo_alv,
x_layout type slis_layout_alv,
y_layout type slis_layout_alv,
gd_layout type lvc_s_layo,
x_print type slis_print_alv,
x_variant type disvariant,
d_repid type sy-repid,
ct_type(2) ,
f_fldcat2 type slis_t_fieldcat_alv with header line,
g_layout type slis_layout_alv,
gs_fieldcatalog type lvc_s_fcat occurs 0,
gv_fcat like line of gs_fieldcatalog,
gus_fieldcatalog type lvc_s_fcat occurs 0.
data : rs_selfield type slis_selfield.
data: ok_code like sy-ucomm,
save_ok like sy-ucomm,
g_container type scrfname value 'ZCTRUSER',
grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container,
gs_layout type lvc_s_layo,
g_max type i value 100.
data: it_folder like standard table of sdokpath,
it_file like standard table of sdokpath,
it_fol_fil like standard table of sdokpath,
wa_fol_fil like sdokpath,
file_count type i,
dir_count type i.
data : cntr_no(4) type n,
line_no(4) type n.
data : vf_start_col type i, "start column
vf_start_row type i, "start row
vf_end_col type i, "maximum column
vf_end_row type i, "maximum row
p_text(20).
data: itabb type standard table of kcde_cells with header line,
vf_index type i.
data: tab type table of itab,
wa_tab like itab.
data gd_matnr type matnr.
data p_psavep type string value 'Park Document template.XLS'.
field-symbols: <fs>.
selection-screen begin of block sel1 with frame title text-003.
*PARAMETERS : RB_UP RADIOBUTTON GROUP RB_1 DEFAULT 'X' USER-COMMAND ucom.
parameters : p_fname type ibipparms-path .
*SELECTION-SCREEN SKIP 1.
*PARAMETERS : RB_TMP RADIOBUTTON GROUP RB_1.
*PARAMETER : p_pdirp TYPE pfeflnamel DEFAULT 'D:\'.
* p_psavep TYPE string DEFAULT 'Park Document template.XLS'.
*SELECTION-SCREEN SKIP 1.
*PARAMETERS : RB_DWN RADIOBUTTON GROUP RB_1.
selection-screen end of block sel1.
at selection-screen output.
perform modify_screen.
at selection-screen on value-request for p_fname.
data: path like rlgrap-filename.
path = 'D:\'.
call function 'WS_FILENAME_GET'
exporting
def_filename = space
def_path = path
* MASK = ',.xls , .xlsx.'
* MASK = ', .txt , .txt.'
mode = 'O'
title = 'PC-File-Selection'
importing
filename = p_fname
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pdirp.
* DATA: fname TYPE string.
*
* CALL METHOD cl_gui_frontend_services=>directory_browse
* EXPORTING
* window_title = 'Select Directory'
* CHANGING
* selected_folder = fname
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* OTHERS = 4.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.
*
* p_pdirp = fname.
*&---------------------------------------------------------------------*
*& Include ZFIEXPLTSEL
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form BINT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form bint .
define f_fldcat.
clear s_fldcat.
s_fldcat-fieldname = &1.
s_fldcat-decimals_out = &2.
s_fldcat-seltext_l = &3.
s_fldcat-outputlen = &4.
s_fldcat-just = &5.
s_fldcat-no_out = &6.
s_fldcat-datatype = &7.
s_fldcat-qfieldname = &8.
s_fldcat-no_zero = &9.
append s_fldcat to t_fldcat.
end-of-definition.
define f_fldcat2.
clear s_fldcat2.
s_fldcat2-fieldname = &1.
s_fldcat2-decimals_out = &2.
s_fldcat2-seltext_l = &3.
s_fldcat2-outputlen = &4.
s_fldcat2-just = &5.
s_fldcat2-no_out = &6.
s_fldcat2-datatype = &7.
s_fldcat2-qfieldname = &8.
s_fldcat2-no_zero = &9.
append s_fldcat2 to t_fldcat2.
end-of-definition.
endform.
*&---------------------------------------------------------------------*
*& Include ZFIEXPLTPRO
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FILL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fill_data .
* SPLIT data Form Excel
vf_start_col = '1'.
vf_start_row = '2'.
vf_end_col = '60'.
vf_end_row = '10000'.
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT' " Function to download data
" from excel
exporting
filename = p_fname
i_begin_col = vf_start_col
i_begin_row = vf_start_row
i_end_col = vf_end_col
i_end_row = vf_end_row
tables
intern = itabb "B09
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
clear: itabb .
sort itabb by row col.
loop at itabb.
move : itabb-col to vf_index.
* assign component vf_index of structure wa_fb01 to <fs>.
assign component vf_index of structure wa_dat to <fs>.
move : itabb-value to <fs>.
at end of row.
* append wa_fb01 to it_FB01.
* clear wa_fb01.
append wa_dat to it_dat.
clear wa_dat.
endat.
endloop.
table_n = 0.
* describe table it_fb01 lines table_n.
describe table it_dat lines table_n.
if table_n eq 0.
message s208(00) with 'Can not Process, Check DAT Please'.
stop.
endif.
* Arrange data
data : g_frm-no(25).
g_line = 1.
loop at it_dat into wa_dat.
translate wa_dat-col_01 to upper case.
move-corresponding wa_dat to wa_date.
* WA_DATE-LINE = G_LINE.
wa_date-col_13 = g_line.
if wa_date-col_01(4) = 'FORM'.
g_line = g_line + 1 .
wa_date-col_13 = g_line.
endif.
append wa_date to it_date.
endloop.
* Delete unneed
delete it_date where col_01(4) = 'DOCU'.
delete it_date where col_01(4) = 'FORM'.
*
.
loop at it_date into wa_date.
at new col_13.
read table it_date into wa_date index sy-tabix.
g_frm-no = wa_date-col_01.
endat.
*
move-corresponding wa_date to wa_dat1.
wa_dat1-col_14 = g_frm-no.
if wa_dat1-col_12 is initial.
wa_dat1-col_15 = '31'.
else.
wa_dat1-col_15 = '40'.
endif.
* CLEAR BKPF-XBLNR.
* SELECT SINGLE XBLNR BELNR
* FROM BKPF INTO (BKPF-XBLNR,BKPF-BELNR)
* WHERE XBLNR EQ WA_DAT1-COL_01
* AND BLART = 'KD'.
**
* IF SY-SUBRC EQ 0.
* WA_DAT1-TRF_LIGHT = '1'.
* CONCATENATE 'Already Create with no. ' BKPF-BELNR INTO DG_STATUS SEPARATED BY SPACE.
* WA_DAT1-STATUS = DG_STATUS.
* ELSE.
* ENDIF.
wa_dat1-col_16 = '1000'.
wa_dat1-col_17 = wa_dat1-col_02+6(4).
append wa_dat1 to it_dat1.
endloop.
it_dat2[] = it_dat1[].
delete adjacent duplicates from it_dat1 comparing col_13.
delete it_dat2 where col_12 eq space.
* CHECK Status data
loop at it_dat1 into wa_dat1.
* IF WA_DAT1-TRF_LIGHT EQ SPACE.
clear bkpf-xblnr.
select single xblnr belnr
from bkpf into (bkpf-xblnr,bkpf-belnr)
where xblnr eq wa_dat1-col_01
and blart = 'KD'.
*
if sy-subrc eq 0.
wa_dat1-trf_light = '1'.
concatenate 'Already Create with no. ' bkpf-belnr into dg_status separated by space.
wa_dat1-status = dg_status.
else.
endif.
if wa_dat1-trf_light ne '1'.
concatenate '000' wa_dat1-col_09 into wa_dat1-col_09.
select single lifnr
into lfa1-lifnr
from lfa1
where lifnr = wa_dat1-col_09.
if sy-subrc eq 0.
wa_dat1-trf_light = '2'.
wa_dat1-status = 'Process'.
else.
wa_dat1-trf_light = '1'.
wa_dat1-status = 'Vendor Does not Exist'.
endif.
endif.
wa_dat1-col_18 = wa_dat1-col_05.
concatenate '0' wa_dat1-col_05+1(3) into wa_dat1-col_18.
modify it_dat1 from wa_dat1.
endloop.
* Combine Data
loop at it_dat1 into wa_dat1.
wa_data-frm_no = wa_dat1-col_01.
wa_data-budat = wa_dat1-col_02.
wa_data-bldat = wa_dat1-col_02.
wa_data-bupla = wa_dat1-col_18.
wa_data-gsber = wa_dat1-col_05.
wa_data-xblnr = wa_dat1-col_01.
wa_data-bukrs = '1000'.
wa_data-waers = 'IDR'.
wa_data-newko = wa_dat1-col_09+3(7).
wa_data-hkont = wa_dat1-col_10.
wa_data-newbs = wa_dat1-col_15.
wa_data-wrbtr = wa_dat1-col_11.
wa_data-kostl = wa_dat1-col_06.
wa_data-hbkid = wa_dat1-col_07.
wa_data-bvtyp = wa_dat1-col_08.
wa_data-newbs = wa_dat1-col_15.
wa_data-gjahr = wa_dat1-col_02+6(4).
wa_data-trf_light = wa_dat1-trf_light.
wa_data-status = it_dat1-status.
append wa_data to it_data.
endloop.
clear : wa_data,wa_dat1,wa_dat2.
sort it_dat1 by col_14.
sort it_dat2 by col_14.
loop at it_dat2 into wa_dat2.
wa_data-frm_no = wa_dat2-col_14.
wa_data-bktxt = wa_dat2-col_02.
read table it_dat1 into wa_dat1 with key col_14 = wa_dat2-col_14.
if sy-subrc eq 0.
wa_data-bupla = wa_dat1-col_18.
wa_data-gsber = wa_dat1-col_05.
wa_data-kostl = wa_dat1-col_06.
wa_data-hkont = wa_dat1-col_10.
endif.
wa_data-zuonr = wa_dat2-col_07.
wa_data-sgtxt = wa_dat2-col_11.
wa_data-xref1 = wa_dat2-col_10.
wa_data-xref2 = wa_dat2-col_03.
wa_data-wrbtr = wa_dat2-col_05.
wa_data-xref3 = 'ref key13'.
wa_data-bukrs = '1000'.
wa_data-matnr = wa_dat2-col_12.
wa_data-newko = space.
wa_data-newbs = wa_dat2-col_15.
wa_data-gjahr = wa_dat2-col_01+6(4).
wa_data-trf_light = wa_dat2-trf_light.
append wa_data to it_data.
endloop.
***Check for New or exist Material
sort it_data by frm_no.
sort it_dat2 by col_14.
loop at it_data into wa_data.
move-corresponding wa_data to wa_fb01.
*
translate wa_fb01-xblnr to upper case.
*
clear bkpf-xblnr.
select single xblnr belnr
from bkpf into (bkpf-xblnr,bkpf-belnr)
where xblnr eq wa_fb01-xblnr
and blart = 'KD'..
*
if sy-subrc eq 0.
wa_fb01-trf_light = '1'.
concatenate 'Already Create with no. ' bkpf-belnr into dg_status separated by space.
wa_fb01-status = dg_status.
else.
wa_fb01-trf_light = '2'.
wa_fb01-status = 'Process'.
endif.
wa_fb01-newbs = '40'.
at new frm_no.
wa_fb01-newbs = '31'.
endat.
read table it_dat2 into wa_dat2 with key col_14 = wa_fb01-frm_no.
if sy-subrc eq 0.
wa_fb01-bktxt = wa_dat2-col_02.
endif.
append wa_fb01 to it_fb01.
endloop.
*First Display
perform first_view_data.
endform. " FILL_DATA
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
form bdc_transaction using tcode.
data: l_mstring(480).
data: l_subrc like sy-subrc.
refresh messtab.
call transaction tcode using bdcdata
mode 'N' " 'N' "'A' "CTUMODE
update 'L' "'L' "'S' "CUPDATE
messages into messtab.
loop at messtab.
message id messtab-msgid
type messtab-msgtyp
number messtab-msgnr
into l_mstring
with messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
it_messtab-msgtyp = messtab-msgtyp.
it_messtab-msgv1 = messtab-msgv1.
it_messtab-msgv2 = messtab-msgv2.
if messtab-msgv2 is not initial.
it_messtab-msgv1 = messtab-msgv2.
endif.
it_messtab-msgv3 = messtab-msgv3.
it_messtab-msgv4 = messtab-msgv4.
it_messtab-l_mstring = l_mstring.
append it_messtab .
endloop.
refresh bdcdata.
endform. "BDC_TRANSACTION
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
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 <> space. "NODATA.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
endif.
endform. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form PROS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form pros_data.
it_fb02 = it_fb01.
delete it_fb02 where newbs = '31'.
delete it_fb01 where newbs = '40'.
sort it_fb01 by trf_light frm_no newbs.
loop at it_fb01 into wa_fb01 where trf_light ne '1'.
perform bdc_dynpro using 'SAPLF040' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF05V-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-BLDAT'
wa_fb01-bldat. "'23.09.2021'.
perform bdc_field using 'BKPF-BLART'
'KD'.
perform bdc_field using 'BKPF-BUKRS'
'1000'.
perform bdc_field using 'BKPF-BUDAT'
wa_fb01-budat. "'23.09.2021'.
perform bdc_field using 'BKPF-MONAT'
'6'.
perform bdc_field using 'BKPF-WAERS'
* WA_FB01-WAERS. "
'IDR'.
perform bdc_field using 'BKPF-WWERT'
wa_fb01-budat. "WWERT. "'23.09.2021'.
perform bdc_field using 'BKPF-XBLNR'
wa_fb01-xblnr. "'Refer 1'.
perform bdc_field using 'BKPF-BKTXT'
wa_fb01-bktxt."'header text'.
perform bdc_field using 'VBKPF-XBWAE'
'X'.
perform bdc_field using 'FS006-DOCID'
'*'.
if wa_fb01-newbs = '31'.
perform bdc_field using 'RF05V-NEWBS'
wa_fb01-newbs."'31'.
perform bdc_field using 'RF05V-NEWKO'
wa_fb01-newko. "'6000073'.
endif.
perform bdc_dynpro using 'SAPLF040' '0302'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=ZK'.
perform bdc_field using 'BSEG-HKONT'
* WA_FB01-HKONT.
'24390-0200'.
perform bdc_field using 'BSEG-WRBTR'
wa_fb01-wrbtr. "'9000000'.
perform bdc_field using 'BSEG-MWSKZ'
'**'.
perform bdc_field using 'BSEG-BUPLA'
wa_fb01-bupla. "'0000'.
perform bdc_field using 'BSEG-GSBER'
wa_fb01-gsber. "'D000'.
perform bdc_field using 'BSEG-ZTERM'
* WA_FB01-ZTERM. "
'V000'.
perform bdc_field using 'BSEG-ZFBDT'
wa_fb01-budat. "'23.09.2021'.
perform bdc_field using 'BSEG-ZLSPR'
* WA_FB01-ZLSPR. "
'A'.
perform bdc_field using 'BSEG-ZLSCH'
* WA_FB01-ZLSCH. "
'T'.
perform bdc_field using 'BSEG-ZUONR'
wa_fb01-zuonr. "'assigment1'.
perform bdc_field using 'BSEG-SGTXT'
wa_fb01-sgtxt. "'test1'.
perform bdc_dynpro using 'SAPLF040' '0332'.
perform bdc_field using 'BDC_CURSOR'
'RF05V-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-BVTYP'
* WA_FB01-BVTYP."
'ID01'.
perform bdc_field using 'BSEG-XREF1'
wa_fb01-xref1 ."'REF KEY1'.
perform bdc_field using 'BSEG-HBKID'
wa_fb01-hbkid. "'BCA01'.
perform bdc_field using 'BSEG-XREF2'
wa_fb01-xref2. "'REF KEY12'.
perform bdc_field using 'BSEG-XREF3'
wa_fb01-xref3. "'ref key13'.
sort it_fb02 by frm_no newbs.
loop at it_fb02 into wa_fb02 where frm_no = wa_fb01-frm_no.
if wa_fb02-newbs = '40'.
perform bdc_field using 'RF05V-NEWBS'
wa_fb02-newbs. "'40'.
perform bdc_field using 'RF05V-NEWKO'
wa_fb02-hkont.
* '52715-0000'.
endif.
perform bdc_dynpro using 'SAPLF040' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=ZK'.
perform bdc_field using 'BSEG-WRBTR'
wa_fb02-wrbtr. "'4500000'.
perform bdc_field using 'BSEG-BUPLA'
wa_fb02-bupla. "'0000'.
perform bdc_field using 'BSEG-ZUONR'
wa_fb02-zuonr. "'assigment2'.
perform bdc_field using 'BSEG-SGTXT'
wa_fb02-sgtxt. "'test2'.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-GSBER'
wa_fb02-gsber. "'D000'.
perform bdc_field using 'COBL-KOSTL'
wa_fb02-kostl. "'jkt0200300'.
perform bdc_field using 'COBL-MATNR'
wa_fb02-matnr. "'ZTR010303060'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLF040' '0330'.
perform bdc_field using 'BDC_CURSOR'
'RF05V-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-XREF1'
wa_fb02-xref1. "'REF KEY1'.
perform bdc_field using 'BSEG-XREF2'
wa_fb02-xref2. "'REF KEY12'.
* AT END OF FRM_NO.
* perform bdc_field using 'BDC_CURSOR'
* 'BSEG-WRBTR'. "'BSEG-XREF2'.
* perform bdc_field using 'BDC_OKCODE'
* '=BP'.
* perform bdc_transaction using 'FBV1'.
* ENDAT.
endloop.
at end of frm_no.
perform bdc_field using 'BDC_CURSOR'
'BSEG-WRBTR'. "'BSEG-XREF2'.
perform bdc_field using 'BDC_OKCODE'
'=BP'.
perform bdc_transaction using 'FBV1'.
clear: wa_dat1,wa_dat2.
endat.
endloop.
* Get Result
sort it_messtab by msgtyp l_mstring.
delete it_messtab where msgtyp ne 'S'.
loop at it_fb01 into wa_fb01.
read table it_messtab index sy-tabix.
if it_messtab-l_mstring(4) eq 'Docu'.
wa_fb01-belnr = it_messtab-l_mstring+9(10).
wa_fb01-status = 'Created'.
wa_fb01-trf_light = 3.
else.
wa_fb01-belnr = space.
if it_messtab-l_mstring = space.
wa_fb01-status = 'Fail to Process'.
else.
wa_fb01-status = 'Fail to Process'..
* WA_FB01-STATUS = IT_MESSTAB-L_MSTRING.
endif.
wa_fb01-trf_light = 1.
endif.
modify it_fb01 from wa_fb01.
endloop.
message ' ' type 'S'.
endform. " PROS_DATA
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_UCOMM text
* -->P_SELFIELD text
*----------------------------------------------------------------------*
form user_command using p_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case p_ucomm.
when '&PRO'.
perform pros_data.
perform end_view_data.
when '&BACK'.
leave to screen 0.
when '&EXIT'.
leave to screen 0.
when '&CNCL'.
leave to screen 0.
endcase.
endform. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form MODIFY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form modify_data.
*
* LOOP AT IT_MM01 INTO WA_MM01.
*
* SELECT SINGLE MATNR FROM MARA INTO MARA-MATNR
* WHERE MATNR EQ WA_MM01-MATNR
* AND PRDHA EQ WA_MM01-PRDHA.
*
* IF SY-SUBRC EQ 0.
* WA_MM01-TRF_LIGHT = '3'. "Green
* WA_MM01-MEINS = 'SET'.
* WA_MM01-MATKL = 'CB-OTH'.
* WA_MM01-MSGE = 'Material Successful Created'.
* ELSE.
* READ TABLE IT_MESSTAB INDEX SY-TABIX.
* WA_MM01-MSGE = 'Material Not Create'.
* WA_MM01-TRF_LIGHT = '1'.
* ENDIF.
* MODIFY IT_MM01 FROM WA_MM01.
* MOVE-CORRESPONDING WA_MM01 TO WA_MMXX.
* APPEND WA_MMXX TO IT_MMXX.
* ENDLOOP.
endform. " MODIFY_DATA
*&---------------------------------------------------------------------*
*& Form MODIFY_MM02
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form modify_mm02 .
*
* LOOP AT IT_MM02 INTO WA_MM02.
* SELECT SINGLE MATNR FROM MARA INTO MARA-MATNR
* WHERE MATNR EQ WA_MM02-MATNR.
*
* IF SY-SUBRC EQ 0.
* WA_MM02-TRF_LIGHT = '3'. "Green
* WA_MM01-MEINS = 'SET'.
* WA_MM01-MATKL = 'CB-OTH'.
* WA_MM02-MSGE = 'Material Changed Successful'.
* ELSE.
* READ TABLE IT_MESSTAB INDEX SY-TABIX.
* WA_MM02-TRF_LIGHT = '1'.
* WA_MM02-MSGE = IT_MESSTAB-L_MSTRING.
* ENDIF.
* MODIFY IT_MM02 FROM WA_MM02.
* MOVE-CORRESPONDING WA_MM02 TO WA_MMXX.
* APPEND WA_MMXX TO IT_MMXX.
* ENDLOOP.
endform. " MODIFY_MM02
*&---------------------------------------------------------------------*
*& Form DWN_TEMPLATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form dwn_template .
data: it_folder like standard table of sdokpath,
it_file like standard table of sdokpath,
it_fol_fil like standard table of sdokpath,
wa_fol_fil like sdokpath,
file_count type i,
dir_count type i.
data : begin of it_join_fields occurs 0,
field_name(20),
end of it_join_fields.
* refresh it_data.
* it_data-FRM_NO = 'FRM_NO '." 'No'.
* it_data-BLDAT = 'BLDAT'." 'Document Type'.
** it_data-BLART = 'BLART'." 'Document Date in Document'.
** it_data-BUKRS = 'BUKRS'." 'Posting Date in the Document'.
* it_data-BUDAT = 'BUDAT'." 'Company Code'.
** it_data-MONAT = 'MONAT'." 'Fiscal Period'.
** it_data-WAERS = 'WAERS'." 'Currency Key'.
** it_data-WWERT = 'WWERT'." 'WW'.
* it_data-XBLNR = 'XBLNR'." 'Reference Document Number'.
* it_data-BKTXT = 'BKTXT'." 'Document Header Text'.
** it_data-XBWAE = 'XBWAE'." 'Only transfer document in document currency when posting'.
** it_data-DOCID = 'DOCID'." 'Doctor key'.
** it_data-NEWBS = 'NEWBS'." 'Posting Key for the Next Line Item'.
* it_data-NEWKO = 'NEWKO'." 'Account or Matchcode for the Next Line Item'.
** it_data-HKONT = 'HKONT'." 'General Ledger Account'.
* it_data-WRBTR = 'WRBTR'." 'Amount in Document Currency'.
** it_data-MWSKZ = 'MWSKZ'." 'Tax on sales/purchases code'.
* it_data-BUPLA = 'BUPLA'." 'Business Place'.
* it_data-GSBER = 'GSBER'." 'Business Area'.
** it_data-ZTERM = 'ZTERM'." 'ZTE'.
** it_data-ZFBDT = 'ZFBDT'." 'ZFB'.
** it_data-ZLSPR = 'ZLSPR'." 'ZLS'.
** it_data-ZLSCH = 'ZLSCH'." 'ZLS'.
* it_data-ZUONR = 'ZUONR'." 'ZUO'.
* it_data-SGTXT = 'SGTXT'." 'Item Text'.
** it_data-BVTYP = 'BVTYP'." 'Partner Bank Type'.
* it_data-XREF1 = 'XREF1'." 'Business Partner Reference Key 1'.
* it_data-HBKID = 'HBKID'." 'Short Key for a House Bank'.
* it_data-XREF2 = 'XREF2'." 'Business Partner Reference Key 2'.
* it_data-XREF3 = 'XREF3'." 'Business Partner Reference Key 3'.
** it_data-FMORE = 'FMORE'." 'FMO'.
* it_data-KOSTL = 'KOSTL'." 'Cost Center'.
* it_data-MATNR = 'MATNR'." 'Material Number'.
*
* append it_data.clear it_data.
* concatenate p_pdirp '\' p_psavep into p_psavep.
*
* if it_data[] is not initial.
* call function 'GUI_DOWNLOAD'
* exporting
* filename = p_psavep " Path and Name of Excel File with Extension .xls
* write_field_separator = 'X'
* tables
* data_tab = it_data " Internal Table having all Name of Folders and
Files
** fieldnames = it_join_fields
* exceptions
* file_write_error = 1
* no_batch = 2
* gui_refuse_filetransfer = 3
* invalid_type = 4
* no_authority = 5
* unknown_error = 6
* header_not_allowed = 7
* separator_not_allowed = 8
* filesize_not_allowed = 9
* header_too_long = 10
* dp_error_create = 11
* dp_error_send = 12
* dp_error_write = 13
* unknown_dp_error = 14
* access_denied = 15
* dp_out_of_memory = 16
* disk_full = 17
* dp_timeout = 18
* file_not_found = 19
* dataprovider_exception = 20
* control_flush_error = 21
* others = 22.
* if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* endif.
* else.
* message: 'No file found in the selected Directory' type 'I'.
* endif.
endform. " DWN_TEMPLATE
*&---------------------------------------------------------------------*
*& Form FISCMONTH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fiscmonth .
* Get Priode date
** wa-fb01-budat(4)g_gjahr-low = s_spmon-low(4).
** g_monat-low = s_spmon-low+4(2).
*
*
*
** Konversi to Japan Year
** Jpn Ina
* if WA_FB01-BUDAT+4(2) = '01' .WA_FB01-MONAT = '04'. endif. "
* if WA_FB01-BUDAT+4(2) = '02' .WA_FB01-MONAT = '05'. endif. "
* if WA_FB01-BUDAT+4(2) = '03' .WA_FB01-MONAT = '06'. endif. "
* if WA_FB01-BUDAT+4(2) = '04' .WA_FB01-MONAT = '07'. endif.
* if WA_FB01-BUDAT+4(2) = '05' .WA_FB01-MONAT = '08'. endif.
* if WA_FB01-BUDAT+4(2) = '06' .WA_FB01-MONAT = '09'. endif.
* if WA_FB01-BUDAT+4(2) = '07' .WA_FB01-MONAT = '10'. endif.
* if WA_FB01-BUDAT+4(2) = '08' .WA_FB01-MONAT = '11'. endif.
* if WA_FB01-BUDAT+4(2) = '09' .WA_FB01-MONAT = '12'. endif.
* if WA_FB01-BUDAT+4(2) = '10' .WA_FB01-MONAT = '01'. endif.
* if WA_FB01-BUDAT+4(2) = '11' .WA_FB01-MONAT = '02'. endif.
* if WA_FB01-BUDAT+4(2) = '12' .WA_FB01-MONAT = '03'. endif.
endform. " FISCMONTH
*&---------------------------------------------------------------------*
*& Include ZFIEXPLTPRT
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_fieldcat .
* * * * 1 2 3 4 5 6 7 8 9
f_fldcat2 'FRM_NO' '' 'Reference' '' 'L' '' 'CHAR' '' '' .
f_fldcat2 'BUKRS' '' 'Comp. Code' '' 'L' '' 'CHAR' '' '' .
f_fldcat2 'GJAHR' '' 'Fiscal Year' '' 'L' '' 'CHAR' '' '' .
f_fldcat2 'BELNR' '' 'Doc. No.' '' 'L' '' 'CHAR' '' '' .
f_fldcat2 'STATUS' '' 'Status ' '' 'L' '' 'CHAR' '' '' .
clear s_fldcat2.
endform. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form L_BUILD_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form l_build_layout .
y_layout-colwidth_optimize = 'X'.
y_layout-info_fieldname = 'LINE_COLOR'.
y_layout-def_status = 'X'.
y_layout-lights_fieldname = 'TRF_LIGHT'.
y_layout-lights_tabname = 'I_LIGHTS'.
endform. " L_BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display .
d_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = d_repid
i_callback_pf_status_set = 'STATUS_SET'
i_callback_user_command = 'USR_CMD'
it_fieldcat = t_fldcat2[]
it_sort = t_sort2[]
is_layout = y_layout
* i_default = 'X'
i_save = 'U'
* is_variant = x_variant
* it_event_exit = t_event_exit[]
* is_print = x_print
tables
t_outtab = it_fb01[]
exceptions
program_error = 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.
endform. " DISPLAY
*&---------------------------------------------------------------------*
*& Form status_set
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
form status_set using rt_extab type slis_t_extab.
set pf-status 'ZALV'.
endform. "f_status_set
*&---------------------------------------------------------------------*
*& Form END_VIEW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form end_view_data . "Sini
rs_selfield-refresh = abap_true.
perform build_fieldcat.
perform l_build_layout.
perform display.
endform. " END_VIEW_DATA
*&---------------------------------------------------------------------*
*& Form FIRST_VIEW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form first_view_data .
perform build_fieldcat_ist.
perform l_build_layout_ist.
perform display_ist.
endform. " FIRST_VIEW_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY_IST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display_ist.
d_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = d_repid
i_callback_pf_status_set = 'STAT_SET'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fldcat[]
it_sort = t_sort[]
is_layout = x_layout
i_default = ''
i_save = ''
tables
t_outtab = it_dat1[] "it_FB01[]
exceptions
program_error = 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.
endform. " DISPLAY_IST
*&---------------------------------------------------------------------*
*& Form L_BUILD_LAYOUT_IST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form l_build_layout_ist .
x_layout-colwidth_optimize = 'X'.
x_layout-info_fieldname = 'LINE_COLOR'.
x_layout-def_status = 'X'.
x_layout-lights_fieldname = 'TRF_LIGHT'.
x_layout-lights_tabname = 'I_LIGHTS'.
endform. " L_BUILD_LAYOUT_IST
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT_IST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_fieldcat_ist.
f_fldcat 'COL_01' '' 'Reference' '' 'L' '' 'CHAR' '' '' .
f_fldcat 'COL_16' '' 'Company Code' '' 'L' '' 'CHAR' '' '' .
f_fldcat 'COL_17' '' 'Year' '' 'L' '' 'CHAR' '' '' .
f_fldcat 'STATUS' '' 'Status data' '' 'L' '' 'CHAR' '' '' .
clear s_fldcat.
endform. " BUILD_FIELDCAT_IST
*&---------------------------------------------------------------------*
*& Form f_status_set
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
form stat_set using rt_extab type slis_t_extab.
set pf-status 'ZALV2'.
endform. "stat_set
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_UCOMM text
* -->P_SELFIELD text
*----------------------------------------------------------------------*
form usr_cmd using p_ucomm like sy-ucomm
rs_selfield type slis_selfield.
if rs_selfield-value(2) = '71' or rs_selfield-value(2) = '82' or
rs_selfield-value(2) = '27' or rs_selfield-value(2) = '33'.
case p_ucomm.
when '&IC1'. " SAP standard code for double-clicking
set parameter id 'BLN' field rs_selfield-value.
set parameter id 'BUK' field '1000'.
set parameter id 'GJR' field wa_fb01-gjahr.
call transaction 'FB03' and skip first screen.
endcase.
clear rs_selfield.
else.
* CASE p_ucomm.
* WHEN '&BACK'.
* SUBMIT Z_DID_FI_EXPE_TRVL via SELECTION-SCREEN.
* ENDCASE.
endif.
case p_ucomm.
when '&BACK'.
submit z_did_fi_expe_trvl via selection-screen.
endcase.
endform. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form MODIFY_SCREEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form modify_screen .
* LOOP AT SCREEN.
* IF RB_UP = 'X' .
* IF screen-name = 'P_PDIRP' OR screen-name = 'P_PSAVEP'.
* screen-input = '0'.
* MODIFY SCREEN.
* ENDIF.
* CLEAR : p_PDIRP,P_PSAVEP.
* ELSEIF RB_TMP = 'X' .
* IF screen-name = 'P_FNAME'.
* screen-input = '0'.
* P_PSAVEP = 'Park Document Template.xls'.
* MODIFY SCREEN.
* ENDIF.
* CLEAR: P_FNAME.
** ELSEIF RB_DWN = 'X'.
** IF screen-name = 'P_FNAME' OR screen-name = 'P_PDIRP' OR screen-name = 'P_PSAVEP'.
** screen-input = '0'.
** MODIFY SCREEN.
** ENDIF.
** CLEAR: p_PDIRP,P_PSAVEP,P_FNAME.
* ELSE.
* IF screen-name = 'P_PDIRP' OR screen-name = 'P_PSAVEP'.
* screen-input = '0'.
* MODIFY SCREEN.
* ENDIF.
* CLEAR: p_PDIRP,P_PSAVEP.
* ENDIF.
*
* ENDLOOP.
endform. " MODIFY_SCREEN