You are on page 1of 12

*&---------------------------------------------------------------------*

*& include zoppc_bdcperforms


*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& form f_upload
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form f_upload .

wf_file = p_inpf.
call function 'gui_upload'
exporting
filename = wf_file
filetype = 'asc'
has_field_separator = 'x'
* header_length = 0
* read_by_line = 'x'
* dat_mode = ' '
* codepage = ' '
* ignore_cerr = abap_true
* replacement = '#'
* check_bom = ' '
* virus_scan_profile =
* no_auth_check = ' '
* importing
* filelength =
* header =
tables
data_tab = int_record
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
.
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*perform open_group.
.

endform. " f_upload

*&---------------------------------------------------------------------*
*& form f_appl_ser
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form f_appl_ser .
if p_l_inpf eq '/cidata/conversion/pp/'.
message text-020 type 's'.
stop.
endif.
open dataset p_l_inpf for input in text mode encoding default.
if sy-subrc ne 0.
exit.
else.
do.
clear: wa_string, int_record_tmp.
read dataset p_l_inpf into wa_string.
if sy-subrc ne 0.
exit.
else.
split wa_string at con_tab into int_record_tmp-matnr
int_record_tmp-werks
int_record_tmp-profidnetz
int_record_tmp-statu
int_record_tmp-verwe
int_record_tmp-losvn
int_record_tmp-losbs

int_record_tmp-vornr
int_record_tmp-phflg
int_record_tmp-pvznr
int_record_tmp-phseq
int_record_tmp-arbpl
int_record_tmp-steus
int_record_tmp-ltxa1

int_record_tmp-bmsch
int_record_tmp-meinh

int_record_tmp-vgw01
int_record_tmp-vge01

int_record_tmp-vgw02
int_record_tmp-vge02
int_record_tmp-lar02

int_record_tmp-vgw03
int_record_tmp-vge03
int_record_tmp-lar03

int_record_tmp-costr_1
int_record_tmp-costr_2
int_record_tmp-costr_3.
move-corresponding int_record_tmp to int_record.
append int_record.
clear int_record.
endif.
enddo.
close dataset p_l_inpf.
endif.
* endif.

describe table int_record lines wf_records_read.

endform. " f_appl_ser

*&---------------------------------------------------------------------*
*& form f_c201_bdc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form f_c201_bdc .

*------------------------------------------------------------------------*
* fm which takes the input as file name and collect the values in flatfile
* to internal table .
*------------------------------------------------------------------------*
loop at int_record. "moving item data into int_opr.
move-corresponding int_record to int_opr.
append int_opr.
clear int_opr.
wc_record = sy-tabix.
endloop.

sort int_opr by vornr.

data: l_mstring(480).

if session = 'x'.
call function 'bdc_open_group'
exporting client = sy-mandt
group = group
user = user
keep = keep
holddate = holddate.
endif
.

loop at int_record. "bdc auto generated code


refresh bdcdata.
if wc_index > wc_record.
exit.
endif.
read table int_record index wc_index.
if sy-subrc <> 0.
continue.
endif.
*****************************************************
perform bdc_dynpro using 'saplcpdi' '4000'.
perform bdc_field using 'bdc_cursor'
'rc271-plnal'.
perform bdc_field using 'bdc_okcode'
'/00'.
perform bdc_field using 'rc271-plnnr'
''.
perform bdc_field using 'rc27m-matnr'
int_record-matnr.
perform bdc_field using 'rc27m-werks'
int_record-werks.
perform bdc_field using 'rc271-profidnetz'
int_record-profidnetz.

*****************************************************
perform bdc_dynpro using 'saplcpda' '4210'.
perform bdc_field using 'bdc_cursor'
'plkod-losvn'.
perform bdc_field using 'bdc_okcode'
'=voue'.
perform bdc_field using 'plkod-verwe'
int_record-verwe.
perform bdc_field using 'plkod-statu'
int_record-statu.
perform bdc_field using 'plkod-bmsch'
int_record-bmsch.
perform bdc_field using 'plkod-losvn'
int_record-losvn.
perform bdc_field using 'plkod-losbs'
int_record-losbs.

*****************************************************
perform bdc_dynpro using 'saplcpdi' '4400'.
perform bdc_field using 'bdc_cursor'
'plpod-vornr(02)'.
perform bdc_field using 'bdc_okcode'
'ent1'.
wc_idx = '1'.

loop at int_opr where matnr = int_record-matnr


and werks = int_record-werks
and profidnetz = int_record-profidnetz.
"looping to fill the table control in operations tab.

concatenate 'plpod-vornr(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-vornr.

concatenate 'rc27x-flg_sel(' wc_idx ')' into wf_fnam.

perform bdc_field using wf_fnam


''.

concatenate 'plpod-phflg(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-phflg.

concatenate 'plpod-phseq(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-phseq .

concatenate 'plpod-arbpl(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-arbpl.

concatenate 'plpod-ltxa1(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-ltxa1.

concatenate 'plpod-pvznr(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-pvznr.

concatenate 'plpod-bmsch(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-bmsch.

concatenate 'plpod-meinh(' wc_idx ')' into wf_fnam.


perform bdc_field using wf_fnam
int_opr-meinh.

wc_idx = wc_idx + 1.
wc_index = wc_index + 1.
clear int_opr.
endloop.
*****************************************************
wc_cntr1 = 1.
loop at int_opr where matnr = int_record-matnr
and werks = int_record-werks
and profidnetz = int_record-profidnetz.
"loopin to fill table control under process instructions tab.

perform bdc_dynpro using 'saplcpdi' '4400'.


perform bdc_field using 'bdc_cursor'
'plpod-vornr(01)'.

if wc_cntr1 > 1.
wc_cntr2 = wc_cntr1 - 1.
concatenate 'rc27x-flg_sel(' wc_cntr2 ')' into wf_fnam.
perform bdc_field using wf_fnam
''.
endif.
if int_opr-phflg = 'x'.
perform bdc_field using 'bdc_okcode'
'=arbd'.
concatenate 'rc27x-flg_sel(' wc_cntr1 ')' into wf_fnam.
perform bdc_field using wf_fnam
'x'.

perform bdc_field using 'rc27x-entry_act'


'1'.
*****************************************************
perform bdc_dynpro using 'saplcpdo' '4410'.
perform bdc_field using 'bdc_cursor'
'plpod-vgw01'.
perform bdc_field using 'bdc_okcode'
'/00'.
perform bdc_field using 'plpod-bmsch'
int_opr-bmsch.
perform bdc_field using 'plpod-meinh'
int_opr-meinh.

perform bdc_field using 'plpod-vgw01'


int_opr-vgw01.
perform bdc_field using 'plpod-vge01'
int_opr-vge01.
*---------------new fields added--------------------
perform bdc_field using 'plpod-vgw02'
int_opr-vgw02.
perform bdc_field using 'plpod-vge02'
int_opr-vge02.
perform bdc_field using 'plpod-lar02'
int_opr-lar02.

perform bdc_field using 'plpod-vgw03'


int_opr-vgw03.
perform bdc_field using 'plpod-vge03'
int_opr-vge03.
perform bdc_field using 'plpod-lar03'
int_opr-lar03.
*----------------------------------------------------

*****************************************************
perform bdc_dynpro using 'saplcpdo' '4410'.
perform bdc_field using 'bdc_cursor'
'plpod-vornr'.
perform bdc_field using 'bdc_okcode'
'=back'.

*****************************************************
perform bdc_dynpro using 'saplcpdi' '4400'.
perform bdc_field using 'bdc_cursor'
'plpod-vornr(01)'.
perform bdc_field using 'bdc_okcode'
'=ftue'.
perform bdc_field using 'rc27x-entry_act'
'1'.

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

perform bdc_dynpro using 'saplc4di' '4700'.


perform bdc_field using 'bdc_cursor'
'plftd-costr(01)'.
perform bdc_field using 'bdc_okcode'
'/00'.
perform bdc_field using 'plftd-costr(01)'
int_opr-costr_1.
perform bdc_field using 'plftd-costr(02)'
int_opr-costr_2.
perform bdc_field using 'plftd-costr(03)'
int_opr-costr_3.

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

perform bdc_dynpro using 'saplc4di' '4700'.


perform bdc_field using 'bdc_cursor'
'plftd-ftrnr(01)'.
perform bdc_field using 'bdc_okcode'
'=back'.
perform bdc_field using 'rc27x-entry_act' '1'.

wc_cntr1 = wc_cntr1 + 1..


else.

perform bdc_field using 'bdc_okcode'


'/00'.

wc_cntr1 = wc_cntr1 + 1.
continue.

endif.
clear int_opr.
endloop.
*************************************************************
perform bdc_dynpro using 'saplcpdi' '4400'.
perform bdc_field using 'bdc_cursor'
'plpod-vornr(01)'.
perform bdc_field using 'bdc_okcode'
'=end'.
perform bdc_field using 'rc27x-entry_act' '1'.

*************************************************************
perform bdc_dynpro using 'saplspo1' '0100'.
perform bdc_field using 'bdc_okcode'
'=yes'.

*************************************************************
perform f_bdc_transaction using 'c201' changing l_mstring.
.

if int_messtab-msgtyp = 's'.
int_audit-matnr = int_record-matnr.
int_audit-status = text-002.
int_audit-message = l_mstring.
wc_pro = wc_pro + wc_idx - 1.
append int_audit.

elseif int_messtab-msgtyp = 'e' and int_messtab-msgnr = '305'.


int_audit-matnr = int_record-matnr.
int_audit-status = text-001.
int_audit-message = l_mstring.
wc_postfail = wc_postfail + wc_idx - 1.
append int_audit.
else.
int_audit-matnr = int_record-matnr.
int_audit-status = text-001.
int_audit-message = l_mstring.
wc_valfail = wc_valfail + wc_idx - 1.
append int_audit.
clear int_audit.
endif.

clear int_record.
endloop.
perform close_group.
endform. " f_c201_bdc
*&---------------------------------------------------------------------*
*& form f_alvdisplay
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form f_alvdisplay .

*&---------------------------------------------------------------------*
*& catalog building
*&---------------------------------------------------------------------*

wa_fieldcat-fieldname = 'matnr'. " the field name and the table


wa_fieldcat-tabname = 'int_audit'. " name are the two minimum req.
wa_fieldcat-key = 'x'. " specifies the column as a key
(blue)
wa_fieldcat-seltext_m = text-021. " column header
append wa_fieldcat to int_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'status'. " the field name and the table


wa_fieldcat-tabname = 'int_audit'. " name are the two minimum req.
wa_fieldcat-seltext_m = text-022. " column header
append wa_fieldcat to int_fieldcat.
clear wa_fieldcat.

wa_fieldcat-fieldname = 'message'. " the field name and the table


wa_fieldcat-tabname = 'int_audit'. " name are the two minimum req.
wa_fieldcat-seltext_m = text-023. " column header
append wa_fieldcat to int_fieldcat.
clear wa_fieldcat.
*&---------------------------------------------------------------------*
*& this fm gives output in alv grid .
*&---------------------------------------------------------------------*

call function 'reuse_alv_grid_display'


exporting
* i_interface_check = ' '
* i_bypassing_buffer = ' '
* i_buffer_active = ' '
i_callback_program = sy-repid "program
name
* i_callback_pf_status_set = ''
* i_callback_user_command = ''
i_callback_top_of_page = 'top_of_page' "header
* i_callback_html_top_of_page = ' '
* i_callback_html_end_of_list = ' '
* i_structure_name = ''
* i_background_id = ''
i_grid_title = text-024 "grid heading
* i_grid_settings =
* is_layout =
it_fieldcat = int_fieldcat "name of
the catalog.
* it_excluding =
* it_special_groups =
* it_sort =
* it_filter =

tables
t_outtab = int_audit "name of
the internal table
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.

else.

endif.

endform. " f_alvdisplay

*&---------------------------------------------------------------------*
*& form for making header .
*&---------------------------------------------------------------------*

form top_of_page .

data: fs_line type slis_listheader.


clear int_header.
clear fs_line.
fs_line-typ = 'h'.
fs_line-info = text-025.
append fs_line to int_header.
clear fs_line
.
concatenate text-026 wc_record into wf_line separated by
space.
fs_line-typ = 'a'.
fs_line-info = wf_line.
append fs_line to int_header.
clear fs_line.

concatenate text-027 wc_postfail into wf_line separated by space.


fs_line-typ = 'a'.
fs_line-info = wf_line.
append fs_line to int_header.
clear fs_line.

concatenate text-028 wc_valfail into wf_line separated by space.


fs_line-typ = 'a'.
fs_line-info = wf_line.
append fs_line to int_header.
clear fs_line.

concatenate text-029 wc_pro into wf_line separated by space.

fs_line-typ = 'a'.
fs_line-info = wf_line.
append fs_line to int_header.
clear fs_line.
* f3000_build_header

call function 'reuse_alv_commentary_write'


exporting
it_list_commentary = int_header.

endform. "top_of_page
*&---------------------------------------------------------------------*
*& form f_getserverfile
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form f_getserverfile .
call function '/sapdmc/lsm_f4_server_file'
exporting
directory = '/cidata/conversion/pp/ '
filemask = ' '
importing
serverfile = p_l_inpf
exceptions
canceled_by_user = 1
others = 2
.
if sy-subrc <> 0.
message text-030 type 'e'.
exit.
else.
p_l_inpf = p_l_inpf.
endif.

endform. " f_getserverfile


*&---------------------------------------------------------------------*
*& form f_bdc_transaction
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_0652 text
*----------------------------------------------------------------------*
form f_bdc_transaction using tcode changing l_mstring.

* data: l_mstring(480).
data: l_subrc like sy-subrc.
* batch input session
if session = 'x'.
call function 'bdc_insert'
exporting tcode = tcode
tables dynprotab = bdcdata.
if smalllog <> 'x'.
* write: / 'bdc_insert'(i03),
* tcode,
* 'returncode:'(i05),
* sy-subrc,
* 'record:',
* sy-index.
endif.
* call transaction using
else.
refresh int_messtab.
call transaction tcode using bdcdata
mode ctumode
update cupdate
messages into int_messtab.
l_subrc = sy-subrc.
if smalllog <> 'x'.
* write: / 'call_transaction',
* tcode,
* 'returncode:'(i05),
* l_subrc,
* 'record:',
* sy-index.
loop at int_messtab.
select single * from t100 where sprsl = int_messtab-msgspra
and arbgb = int_messtab-msgid
and msgnr = int_messtab-msgnr.
if sy-subrc = 0.
l_mstring = t100-text.
if l_mstring cs '&1'.
replace '&1' with int_messtab-msgv1 into l_mstring.
replace '&2' with int_messtab-msgv2 into l_mstring.
replace '&3' with int_messtab-msgv3 into l_mstring.
replace '&4' with int_messtab-msgv4 into l_mstring.
else.
replace '&' with int_messtab-msgv1 into l_mstring.
replace '&' with int_messtab-msgv2 into l_mstring.
replace '&' with int_messtab-msgv3 into l_mstring.
replace '&' with int_messtab-msgv4 into l_mstring.
endif.
condense l_mstring.
* write: / int_messtab-msgtyp, l_mstring(250).
else.
* write: / int_messtab.
endif.
endloop.
* skip.
endif.
** erzeugen fehlermappe ************************************************
if l_subrc <> 0 and e_group <> space.
if e_group_opened = ' '.
call function 'bdc_open_group'
exporting client = sy-mandt
group = e_group
user = e_user
keep = e_keep
holddate = e_hdate.
e_group_opened = 'x'.
endif.
call function 'bdc_insert'
exporting tcode = tcode
tables dynprotab = bdcdata.
endif.
endif.
refresh bdcdata.

endform. " f_bdc_transaction

You might also like