2008 Apr 21 7:58 AM
Hi
Any one please send the sample bdc code for tcode f-02
Thanks
Amiya
2008 Apr 21 8:09 AM
Hi
Any one please send the sample bdc code for tcode f-02
Thanks
Amiya
2008 Apr 21 8:03 AM
report zmna_csf_glc_f02
no standard page heading
message-id 38
line-size 132
line-count 62.
************************************************************************
Program Name: ZMNA_CSF_GLC_F02 *
Author : Tuan Pham *
Company: Motts North America *
Date : 12/27/2001 *
Purpose: This program uploads Premier general ledger and load *
them into R/3 via transaction F-02. *
*
Description: Read Premier general ledger records and create BDC *
statement to load them into R/3 Motts system via *
traasaction F-02. *
Requested By: Vic Alleva *
Input: N/A *
Output: N/A *
Job: N/A *
Transport/Correction #: MRDK902592 / MRDK902593 *
************************************************************************
======================================================================
M O D I F I C A T I O N H I S T O R Y *
======================================================================
Date User Description *
12/27/01 PHAMT Initial *
*
************************************************************************
************************START M2MR************************************
Date : 09-Jan-05 *
Changed By : Nilesh Shete *
Change code : M2MR *
Transport. Req: SD5K911567 *
RevTrac No. : 5000054 *
Ticket No. : 16581306
Description : Analysis of code indicated impact due to M2MR *
conversion ; however, it was determined to be *
out of scope after business review .All *
impacted out of scope programs have been *
updated with Function Module ZCSS_M2MR_EXCEPTIONS *
to prevent execution and provide the user *
with the following message: *
Please note that this program was identified *
as being impacted by the M2MR project but not *
made M2MR compliant as a result of being *
removed from scope per the Business.Please *
contact the helpdesk if you wish to utilize *
this program as it will need to be altered to *
be made M2MR complaint. Thank you. *
************************END M2MR************************************
tables: t100,
anla.
************************************************************************
*
*----- PARAMETERS AND SELECT-OPTIONS DEFINITION -
*
************************************************************************
parameters: p_monat like bkpf-monat default '13' obligatory.
parameters: p_bldat like bkpf-bldat default sy-datum obligatory.
parameters: p_budat like bkpf-budat default sy-datum obligatory.
parameters: p_blart like bkpf-blart default 'SA' obligatory.
parameters: p_bukrs like bkpf-bukrs default '0140' obligatory.
parameters: p_waers like bkpf-waers default 'USD' obligatory.
parameters: p_bktxt like bkpf-bktxt obligatory
default 'Premier Initial Load'.
parameters: p_xblnr like bkpf-xblnr obligatory
default 'Premier Load'.
selection-screen begin of block b1 with frame title text-001.
parameters: p_glfle(70) default 'C:\Motts\IBC_122001.PRN'.
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
selection-screen begin of line.
parameters: p_bdce radiobutton group mod.
selection-screen comment 04(76) text-003.
selection-screen end of line.
selection-screen begin of line.
parameters: p_bdca radiobutton group mod.
selection-screen comment 04(76) text-004.
selection-screen end of line.
selection-screen begin of line.
parameters: p_bdcn radiobutton group mod.
selection-screen comment 04(76) text-005.
selection-screen end of line.
selection-screen skip 1.
selection-screen begin of line.
parameters: p_test radiobutton group upd.
selection-screen comment 04(76) text-006.
selection-screen end of line.
selection-screen begin of line.
parameters: p_stop radiobutton group upd.
selection-screen comment 04(76) text-007.
selection-screen end of line.
selection-screen begin of line.
parameters: p_upd radiobutton group upd.
selection-screen comment 04(76) text-012.
selection-screen end of line.
selection-screen end of block b2.
************************************************************************
*
*----- INTERNAL TABLES -
*
************************************************************************
data: begin of bdc_data occurs 100.
include structure bdcdata.
data: end of bdc_data.
data: begin of i_inrec occurs 0,
line(500) type c,
end of i_inrec.
data: begin of i_glrec occurs 0, "General ledger recs
budat like bkpf-budat, "Posting date
newbs like rf05a-newbs, "Posting key
newko like rf05a-newko, "Account
wrbtr(15) type c, "Amount
bldate(10) type c, "Base line date
invoice(10) type c, "Invoice
po(20) type c, "P.O
name(40) type c, "Customer name
kunnr like bseg-kunnr, "Sold-to number
kostl like bseg-kostl, "Cost center
mwskz like bseg-mwskz, "Tax code
txjcd like bset-txjcd, "Tax jurisdiction
sales_grp(3) type c, "Sales group
prod_hier(27) type c, "Product hierarchy
zuonr like bseg-zuonr, "Allocation
sgtxt like bseg-sgtxt, "Text
aufnr like bseg-aufnr, "Internal order
newbk like rf05a-newbk, "New company code
werks like cobl-werks, "Plant
profit(10) type c, "Profit center
custhier(10) type c, "Customer hierarchy 1
salesoff(4) type c, "Sales office
cotrade(3) type c, "Class of trade
custhie3(10) type c, "Customer hierarchy 3
end of i_glrec.
data: begin of i_errec occurs 0, "Error recs
budat like bkpf-budat, "Posting date
newbs like rf05a-newbs, "Posting key
newko like rf05a-newko, "Account
wrbtr(15) type c, "Amount
bldate(10) type c, "Base line date
invoice(10) type c, "Invoice
po(20) type c, "P.O
name(40) type c, "Customer name
kunnr like bseg-kunnr, "Sold-to number
end of i_errec.
************************************************************************
*
*----- VARIABLES & DATA FIELDS -
*
************************************************************************
data: head0(60) type c.
data: head1(80) type c.
data: head2(80) type c.
data: title(60) type c.
data: stop_flag type c.
data: rec_cnt type i.
data: v_move_type(3) type c.
data: v_bldat(10) type c.
data: v_budat(10) type c.
data: v_pk(2) type c.
data: v_hdr_pk(2) type c.
data: v_hdr_accnt(10) type c.
data: v_tot(12) type c.
data: v_rc like sy-subrc.
data: v_hdr_amt(12) type c.
data: v_itm_amt(12) type c.
data: v_itm_bldte(10) type c.
data: v_hdr_asgm(18) type c.
data: v_itm_asgm(18) type c.
data: v_itm_txt(40) type c.
data: request type c.
data: v_glrec_cnt type i.
data: req_541_rec type i.
data: req_502_rec type i.
data: zmode type c.
data: message_tab like bdcmsgcoll occurs 0 with header line.
data: outfile(50) type c,
msgtext(70) type c,
errcode(10) type c,
msg(12) type c,
err_found type c,
chr_flag type c,
wsfile like rlgrap-filename,
w_length type p,
othclien(3) type c value '000',
upiclien(3) type c,
tlines like sy-index,
error(1) type c value 'F'.
data: duplicate_cntr type i,
bad_cntr type i,
new_acc_cnt type i,
good_cntr type i,
download_cntr type i,
upload_cntr type i,
loop_cntr type i,
w_subcont(1) type c.
*************************START M2MR**********************************
*In the Initialization part of the Program the function module is used
*ZCSS_M2MR_EXCEPTIONS to avoid the execution of the program .
Load-of-program.
CALL FUNCTION 'ZCSS_M2MR_EXCEPTIONS'.
************************END M2MR***********************************
initialization.
************************************************************************
*
----- START-OF_SELECTION -
*
************************************************************************
start-of-selection.
perform 100_upload_glrec using p_glfle.
if stop_flag ne 'Y'.
perform 200_trans_f02.
endif.
end-of-selection.
skip 2.
write: /05 'Control Status'.
write: /08 'Total G/L records read ', 50 ':',
v_glrec_cnt.
write: /08 'Total G/L records created ', 50 ':',
new_acc_cnt.
skip.
write: /01 sy-uline(25), 'E N D - O F - R E P O R T', sy-uline(25).
************************************************************************
**-- FORM: 200_TRANS_F02 --**
************************************************************************
form 200_trans_f02.
if p_bdce ne ' '.
zmode = 'E'.
elseif p_bdca ne ' '.
zmode = 'A'.
else.
zmode = 'N'.
endif.
rec_cnt = 0.
describe table i_glrec lines v_glrec_cnt.
clear bdc_data.
refresh: bdc_data, message_tab.
read table i_glrec index 1.
perform 310_f02_screen_0100.
perform 320_f02_screen_0300.
perform 710_write-header.
concatenate i_glrec-invoice i_glrec-po into v_itm_asgm
separated by ' '.
concatenate i_glrec-name i_glrec-kunnr into v_itm_txt
separated by ' '.
v_itm_amt = i_glrec-wrbtr.
v_itm_bldte = i_glrec-bldate.
perform 700_write-detail.
loop at i_glrec from 2.
perform 320_f02_screen_0301.
perform 700_write-detail.
concatenate i_glrec-invoice i_glrec-po into v_itm_asgm
separated by ' '.
concatenate i_glrec-name i_glrec-kunnr into v_itm_txt
separated by ' '.
v_itm_amt = i_glrec-wrbtr.
v_itm_bldte = i_glrec-bldate.
endloop.
perform 350_f02_screen_0301.
perform 340_f02_screen_0301.
call transaction 'F-02' using bdc_data mode zmode update 'S'
messages into message_tab.
perform 800_get_bdc_error.
endform.
************************************************************************
**-- FORM: 600_DYNPRO --**
************************************************************************
form 600_dynpro using dynbegin fnam fval.
clear bdc_data.
if dynbegin = 'X'.
move fnam to bdc_data-program.
move fval to bdc_data-dynpro.
else.
move fnam to bdc_data-fnam.
move fval to bdc_data-fval.
endif.
move dynbegin to bdc_data-dynbegin.
append bdc_data.
endform.
----
FORM 700_WRITE-DETAIL *
----
form 700_write-detail.
write: /01 i_glrec-newbs,
11 i_glrec-newko,
21 i_glrec-wrbtr,
37 i_glrec-bldate,
48 i_glrec-invoice,
59 i_glrec-po,
80 i_glrec-kunnr,
90 i_glrec-name.
endform.
----
FORM 710_WRITE-HEADER *
----
form 710_write-header.
write: /01 v_hdr_pk,
11 v_hdr_Accnt,
21 v_hdr_amt,
37 p_budat,
48 p_monat,
59 p_bukrs,
80 v_hdr_accnt,
90 p_xblnr.
skip 1.
endform.
************************************************************************
**-- FORM: 100_UPLOAD_GLREC --**
************************************************************************
form: 100_upload_glrec using f_name.
move f_name to wsfile.
stop_flag = 'N'.
call function 'WS_UPLOAD'
exporting
filename = wsfile
filetype = 'ASC'
importing
filesize = w_length
tables
data_tab = i_inrec
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.
if sy-subrc <> 0.
call function 'UPLOAD'
exporting
filename = wsfile
filetype = 'ASC'
importing
filesize = w_length
tables
data_tab = i_inrec
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.
if sy-subrc ne 0.
message e999(fg) with 'Upload G/L file' wsfile
'has error. Check your file.'.
stop_flag = 'Y'.
endif.
endif.
describe table i_inrec lines rec_cnt.
if rec_cnt = 0.
stop_flag = 'Y'.
exit.
endif.
clear: v_hdr_accnt,
v_hdr_pk,
v_tot,
v_hdr_amt,
v_hdr_asgm.
refresh: i_glrec, i_errec.
loop at i_inrec.
v_pk = i_inrec-line+7(2).
if v_pk co '0123456789'.
if v_hdr_accnt = ' '.
v_hdr_accnt = i_inrec-line+13(07).
v_hdr_pk = v_pk.
v_hdr_amt = i_inrec-line+18(12).
v_hdr_asgm = i_inrec-line+40(40).
else.
i_glrec-newbs = v_pk.
i_glrec-newko = i_inrec-line+10(07).
i_glrec-wrbtr = i_inrec-line+18(12).
search i_glrec-wrbtr for '('.
if sy-subrc = 0 and v_pk ne '11'.
concatenate '-' i_glrec-wrbtr into i_glrec-wrbtr.
i_errec = i_glrec.
append i_errec.
endif.
translate i_glrec-wrbtr using ', '.
condense i_glrec-wrbtr no-gaps.
translate i_glrec-wrbtr using '( '.
translate i_glrec-wrbtr using ') '.
i_glrec-bldate = i_inrec-line+32(08).
i_glrec-invoice = i_inrec-line+42(08).
i_glrec-po = i_inrec-line+51(12).
i_glrec-name = i_inrec-line+64(40).
i_glrec-kunnr = i_inrec-line+108(6).
append i_glrec.
if v_pk = '01'.
v_tot = v_tot + i_glrec-wrbtr.
else.
v_tot = v_tot - i_glrec-wrbtr.
endif.
endif.
endif.
endloop.
describe table i_errec lines rec_cnt.
write v_hdr_amt to v_hdr_amt right-justified.
write v_tot to v_tot right-justified.
if rec_cnt > 0.
skip 1.
write: /05 'Negative number found for posting key not 11.'.
skip 1.
loop at i_errec.
write: /01 i_errec-newbs,
11 i_errec-newko,
21 i_errec-wrbtr,
37 i_errec-bldate,
48 i_errec-invoice,
59 i_errec-po,
80 i_errec-kunnr,
90 i_errec-name.
endloop.
elseif v_tot ne v_hdr_amt.
skip 1.
write: /05 'Total header amount', v_hdr_amt, 'is not equal to',
'total item amount', v_tot.
skip 1.
message i999(fg) with 'Total header amount' v_hdr_amt
'not equal total item amount' v_tot.
endif.
endform.
************************************************************************
**-- FORM: 320_F02_SCREEN_0301. --**
************************************************************************
form: 320_f02_screen_0301.
perform 600_dynpro
using: 'X' 'SAPMF05A' '0301',
' ' 'BSEG-WRBTR' v_itm_amt, "Item amount
' ' 'BSEG-ZFBDT' v_itm_bldte, "Base line dt
' ' 'BSEG-ZUONR' v_itm_asgm, "Assignment
' ' 'BSEG-SGTXT' v_itm_txt, "text
' ' 'RF05A-NEWBS' i_glrec-newbs, "Pstky
' ' 'RF05A-NEWKO' i_glrec-newko, "Account
' ' 'BDC_OKCODE' '/00'.
endform.
************************************************************************
**-- FORM: 350_F02_SCREEN_0301. --**
************************************************************************
form: 350_f02_screen_0301.
perform 600_dynpro
using: 'X' 'SAPMF05A' '0301',
' ' 'BSEG-WRBTR' v_itm_amt, "Item amount
' ' 'BSEG-ZFBDT' v_itm_bldte, "Base line dt
' ' 'BSEG-ZUONR' v_itm_asgm, "Assignment
' ' 'BSEG-SGTXT' v_itm_txt. "text
endform.
************************************************************************
**-- FORM: 340_F02_SCREEN_0301. --**
************************************************************************
form: 340_f02_screen_0301.
if p_upd ne ' '.
perform 600_dynpro
using: ' ' 'BDC_OKCODE' '/11'.
elseif p_test ne ' '.
perform 600_dynpro
using: ' ' 'BDC_OKCODE' '/N'.
endif.
endform.
************************************************************************
**-- FORM: 310_F02_SCREEN_0100. --**
************************************************************************
form 310_f02_screen_0100.
concatenate p_bldat4(2) '/' p_bldat6(2) '/' p_bldat(4)
into v_bldat.
concatenate p_budat4(2) '/' p_budat6(2) '/' p_budat(4)
into v_budat.
perform 600_dynpro
using: 'X' 'SAPMF05A' '0100',
' ' 'BKPF-BLDAT' v_bldat, "Document date
' ' 'BKPF-BUDAT' v_budat, "Posting date
' ' 'BKPF-BLART' 'SA', "Doc. type
' ' 'BKPF-BUKRS' p_bukrs, "Company code
' ' 'BKPF-MONAT' p_monat, "Period
' ' 'BKPF-BKTXT' p_bktxt, "Header text
' ' 'BKPF-XBLNR' p_xblnr, "Reference
' ' 'BKPF-WAERS' p_waers, "Currency
' ' 'RF05A-NEWBS' v_hdr_pk, "Pstky
' ' 'RF05A-NEWKO' v_hdr_accnt, "Account
' ' 'BDC_OKCODE' '/00'.
endform.
************************************************************************
**-- FORM: 320_F02_SCREEN_0300. --**
************************************************************************
form 320_f02_screen_0300.
perform 600_dynpro
using: 'X' 'SAPMF05A' '0300',
' ' 'BSEG-WRBTR' v_hdr_amt, "Header amount
' ' 'BSEG-SGTXT' p_bktxt, "Header text
' ' 'BSEG-ZUONR' p_xblnr, "Assignment: Refer
' ' 'RF05A-NEWBS' i_glrec-newbs, "Pstky
' ' 'RF05A-NEWKO' i_glrec-newko, "Account
' ' 'BDC_OKCODE' '/00'.
perform 600_dynpro
using: 'X' 'SAPLKACB' '0002',
' ' 'BDC_OKCODE' '/08'.
endform.
************************************************************************
**-- FORM: 800_GET_BDC_ERROR --**
************************************************************************
form 800_get_bdc_error.
clear: errcode, msgtext, err_found.
msg = 'BDC status:'.
read table message_tab with key msgtyp = 'S'
msgnr = '312'
msgid = 'F5'.
loop at message_tab.
get time.
select single * from t100
where sprsl = message_tab-msgspra
and arbgb = message_tab-msgid
and msgnr = message_tab-msgnr.
shift: message_tab-msgv1 left deleting leading space,
message_tab-msgv2 left deleting leading space,
message_tab-msgv3 left deleting leading space,
message_tab-msgv4 left deleting leading space.
msgtext = t100-text.
replace '&' with message_tab-msgv1(20) into msgtext.
replace '&' with message_tab-msgv2(20) into msgtext.
replace '&' with message_tab-msgv3(20) into msgtext.
replace '&' with message_tab-msgv4(20) into msgtext.
condense msgtext.
concatenate message_tab-msgtyp
message_tab-msgnr '('
message_tab-msgid '):' into errcode.
if message_tab-msgtyp = 'S'.
new_acc_cnt = new_acc_cnt + 1.
if message_tab-msgnr = '312' and message_tab-msgid = 'F5'.
format color col_positive intensified on.
else.
format color col_total intensified off.
endif.
elseif message_tab-msgtyp = 'W'.
format color col_positive intensified off.
else.
format color col_negative.
err_found = 'Y'.
endif.
write: /01 msg, errcode, msgtext.
msg = ' '.
format color col_background.
endloop.
if err_found = 'Y'.
good_cntr = good_cntr + 1.
else.
bad_cntr = bad_cntr + 1.
endif.
endform. "800_GET_BDC_ERROR
*
************************************************************************
*----
************************************************************************
*
top-of-page.
format color col_heading intensified on.
title = 'Premier Material Load'.
head1 = 'BDC Load Status'.
perform 1000_top_of_page using title head1.
format color col_background.
write: /01 'Post-Key', 11 'Account', 21 'Amount', 37 'Post-Date',
48 'Document', 59 'P.O', 80 'Customer', 90 'Name'.
uline: /01(9), 11(09), 21(09), 21(12), 37(10), 48(9), 59(20),
80(9), 90(40).
skip 1.
&----
*& Form 1000_TOP_OF_PAGE
&----
form 1000_top_of_page using text1 text2.
data: wl_title(50) value 'MOTTS'.
data: wf_len1 type i,
wf_len2 type i,
wf_len3 type i,
wf_off1 type i,
wf_off2 type i,
wf_off3 type i,
wf_of11 type i,
wf_of12 type i,
wf_of13 type i,
wf_of14 type i.
data: wf_linsz like syst-linsz.
data: wf_pagno(4),
z_system_id(10).
move syst-linsz to wf_linsz.
compute wf_len1 = strlen( wl_title ).
compute wf_len2 = strlen( text1 ).
compute wf_len3 = strlen( text2 ).
compute wf_off1 = ( wf_linsz - wf_len1 ) / 2.
compute wf_off2 = ( wf_linsz - wf_len2 ) / 2.
compute wf_off3 = ( wf_linsz - wf_len3 ) / 2.
compute wf_of11 = ( wf_linsz - 10 ).
compute wf_of12 = ( wf_linsz - 16 ).
compute wf_of13 = ( wf_linsz - wf_len3 ).
move syst-pagno to wf_pagno.
concatenate syst-sysid '-' syst-mandt into z_system_id.
write:/ 'Report:', syst-cprog. position wf_off1.
write: wl_title. position wf_of12.
write: 'Page:', wf_pagno, ' '.
write:/ 'System:', z_system_id. position wf_off2.
write: text1.position wf_of12.
write: 'Date:', syst-datum.
write:/ 'User :', syst-uname. position wf_off3.
write: text2. position wf_of12.
write: 'Time:', syst-uzeit.
endform. " 1000_TOP_OF_PAGE
2008 Apr 21 8:09 AM
2008 Apr 21 8:22 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |