2006 Jan 11 2:09 PM
Please send me some sample exicuted complete programs regarding <b>below topics.</b>
a)idoc inbound development
b)idoc outbound development
c)idoc inbound process
d)idoc outboun process
e)idoc configuration
f)idoc inbound scheduling.
in process methods:
a)from message control.
b)from stand alone programs.
c)from change pointers.
Please send me reply
see ale edi idocs by aravind nagpal, in there example programms are there. and see the help.sap.com and sapgenie.com,
2006 Jan 20 3:18 PM
see ale edi idocs by aravind nagpal, in there example programms are there. and see the help.sap.com and sapgenie.com,
2006 Jan 20 3:24 PM
Hi,
Check the below code for sample Outbound IDOC.
REPORT ZF_IDOC_OUT_CDS_REF_EXP NO STANDARD PAGE HEADING
LINE-SIZE 165
LINE-COUNT 65
MESSAGE-ID ZF_0.
***********************************************************************
*
Program Name : ZF_IDOC_OUT_CDS_REF_EXP
Title : GM Interface from SAP to CDS Refunds &
Expenditures
interagency invs
Analyst :
Developer :
Date :
Description : Daily Interface of Federal Grant related
expenditure and refund transactions to
CDS.Only records for Business area
implemented on SAP ( begining 7/1 wave 1
agencies,begining 10/1 wave 1&2 agencies,
begining 1/1/03 wave 1,2,&3 agencies )
should be included on the file.
Special Instruction: --
*
***********************************************************************
***********************************************************************
MODIFICATION LOG
*----
Date Correction No. Changed by Description
*----
*
***********************************************************************
*----
Constants
*----
constants : c_idoc_type like edidc-idoctp value 'ZCDS_REF_EXP01',
" used for idoc type
c_message_type like edmsg-msgtyp value 'ZCDS_REF_EXP',
" used for message type
c_rcvprn like edidc-rcvprn value 'COPA_BC',
" used for recieving
" port
c_h value 'H', " header segment -
" hdr_ind
c_bmis(4) value 'BMIS', " header segment -
" ag_id
c_7177877901(10) VALUE '7177877901', " header segment -
" trans_ag_ph
C_AFG840M01(9) VALUE 'AFG840M01', " header segment -
" file_lbl
C_P VALUE 'P', " header segment -
" file_typ_cd
C_FILLER VALUE '', " header segment -
" filler
C_COPA(4) VALUE 'COPA', " Financial management
" area
C_CON(3) VALUE 'CON', " Control segment-
" maint-cd
C_T VALUE 'T', " Trailer segment-
" trlr-ind
C_54(2) VALUE '54', " constant for value
" type
C_95(2) VALUE '95', " constant for value
" type
C_66(2) VALUE '66', " constant for value
" type
C_999900(6) VALUE '999900', " Constant for obj.no
C_XX999999(8) value 'XX999999', " constant for funding
" source
C_KG(2) VALUE 'KG', " Constant for document
" type
C_REF(3) VALUE 'REF', " maintnence code 'REF'
C_EXP(3) VALUE 'EXP', " maintnence code 'EXP'
C_ZQ(2) VALUE 'ZQ', " Constant for document
" type
C_VT(2) VALUE 'VT', " Constant for document
" type
C_KR(2) VALUE 'KR', " Constant for document
" type
C_460(3) VALUE '460', " Constant for item
" text
C_461(3) VALUE '461', " Constant for item
" text
C_462(3) VALUE '462', " Constant for item
" text
C_465(3) VALUE '465', " Constant for item
" text
C_470(3) VALUE '470', " Constant for item
" text
C_1300500(7) VALUE '1300500', " Debit G/l acct.no
C_4000200(7) VALUE '4000200', " Credit G/l acct.no
C_4000300(7) VALUE '4000300', " Credit G/l acct.no
C_TCODE LIKE TSTC-TCODE VALUE 'FB50', " Trans.
" code
C_UPDATE VALUE 'S', " Call trans. update
" mode
C_MODE VALUE 'N', " mode for call trans.
C_GROUP LIKE APQI-GROUPID VALUE 'SFB50'," Session
" group id
c_sb(2) value 'SB', " document type in
" BDC
c_s value 'S', " Debit acct.type
c_C0(2) value 'C0', " Tax code
C_P004(4) value 'P004', " payment term for
" pay upon receipt
c_y3(3) value 'Y%3', " constant for acct.
" type
C_HEADER_SEGMENT LIKE EDIDD-SEGNAM VALUE 'Z1BMISHDR' ,
" header segment name
C_DATA_SEGMENT LIKE EDIDD-SEGNAM VALUE 'Z1BMISDATA',
" data segment name
C_CONTROL_SEGMENT LIKE EDIDD-SEGNAM VALUE 'Z1BMISCON',
" control segment name
C_TRAILER_SEGMENT LIKE EDIDD-SEGNAM VALUE 'Z1BMISTRLR',
" trailer segment name
c_x value 'X', " To manipulate flag
c_success type i value 1, " Success Report
c_failure type i value 2, " Failure Report
c_1 value '1', " outbound
" indicator
c_orp(3) value 'OR%', " constant for
" object number
c_50p(3) value '50%', " constant for fund
c_70p(3) value '70%', " constant for fund
c_80p(3) value '80%', " constant for fund
c_54P(3) value '54%', " constant for
" value type
c_66P(3) value '66%', " constant for
" value type
c_95P(3) value '95%', " constant for
" value type
c_and(1) value '&'.
*----
Table Declarations
*----
tables : fmifiit, " FI Line Item Table in Funds Management
bkpf, " Accounting Document Header
aufk, " Order master data
edp13. " Partner Profile: Outbound (technical
" parameters)
*----
Variables
*----
data : v_total_records type i, " total number of records
v_total_refs type i, " total number of refund
" records
v_total_exps type i, " total number of
" expenditure records
v_total_exp_trbtr type p, " total refund
v_total_ref_trbtr type p, " total expenditure
v_date like sy-datum,
V_MESSTXT(99) TYPE C, " messasge text
v_line type i, " For line number
v_amount LIKE FMIFIIT-trbtr , " For summing amounts
v_cost_center like zfi_t_vfc-zfcrf," cost center
v_mm(2), " to store Month
v_dd(2), " to store Day
v_yy(2), " to store year
v_mmddyy(6), " date in MMDDYY format
v_acc_number(7), " Account number
v_lines type i, " Line number in error tab
v_trbtr(15),
v_zterm like lfb1-zterm, " Payment terms
v_currency like fmifiit-twaer,
v_title like sy-lisel, " Report Title
v_top_amount(14), " field to be passed to
" Fun.Mod which converts
" from lEGACY TO LOCAL DATA
v_linc(4),
v_amountc(13).
*----
Flags
*----
data : f_delete, " to delete record from it_bkpf_fmifiit
f_color, " Flag for color swap
f_flag type i, " Flag to set report title in
f_group . " to indicate batch input session is open
*----
Internal Tables
*----
structures to be filled with segment data
data : X_Z1BMISHDR like Z1BMISHDR,
X_Z1BMISDATA like Z1BMISDATA,
X_Z1BMISCON like Z1BMISCON,
X_Z1BMISTRLR like Z1BMISTRLR.
to hold data from bkpf and fmifiit tables
data : begin of i_bkpf_fmifiit occurs 0,
int_order(12) type c, " internal order number
fonds like fmifiit-fonds, " Fund
fmbelnr like fmifiit-fmbelnr, " Document number for a
" TR-FM line item
KNBELNR like fmifiit-KNBELNR, " FI document number
bus_area like fmifiit-bus_area, " Business Area
objnrz like fmifiit-objnrz, " Object number
wrttp like fmifiit-wrttp, " Value type
trbtr like fmifiit-trbtr, " Amount in trans.
" currency
sgtxt like fmifiit-sgtxt, " Item Text
twaer like fmifiit-twaer,
blart like bkpf-blart, " Document type
auart like aufk-auart, " Order Type
budat like bkpf-budat, " Posting date
bldat like bkpf-bldat, " Document date
end of i_bkpf_fmifiit.
for program messages
data : begin of i_prog_msg occurs 0,
pmsg1(50),
pmsg2(50),
end of i_prog_msg.
control record for IDOC
data : i_edidd like edidd occurs 0 with header line.
Data Record for IDOC
data : begin of i_edidc occurs 1.
include structure edidc.
data : end of i_edidc.
Status record for IDOC
data : begin of i_edidc_comm occurs 1.
include structure edidc.
data : end of i_edidc_comm.
Batch inputdata of single transaction
DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
messages of call transaction
DATA: I_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
*Internal table to store error records
DATA : BEGIN OF I_ERROR_RECORDS OCCURS 0,
line(4), "(internal)inventory-managed material
PMSG(30), " program Error Message
SMSG(80), " system error message
END OF I_ERROR_RECORDS.
*Internal table to store success records
DATA : BEGIN OF I_success_RECORDS OCCURS 0,
document_no(10), " document no
int_order(12), " internal order number
fonds(20), " fund
END OF I_success_RECORDS.
data : x_bkpf_fmifiit like i_bkpf_fmifiit.
*----
Selection-screen
*----
selection-screen : begin of block blk with frame title text-001.
selection-screen skip 1.
select-options : s_b_area for fmifiit-bus_area.
select-options : s_budat for bkpf-budat default sy-datum.
selection-screen : end of block blk.
**----
At selection-screen
**----
AT SELECTION-SCREEN.
perform fill_i_bkpf_fmifiit.
if not i_bkpf_fmifiit[] is initial.
perform delete_i_bkpf_fmifiit.
endif.
find number of records
describe table i_bkpf_fmifiit lines v_total_records.
if v_total_records = 0.
message e000 with 'No records exist'(014).
endif.
*endif.
**----
Start-of-selection
**----
START-OF-SELECTION.
populate control record
perform fill_control_record.
populate header segment
perform build_header_segment.
populate data segment
perform build_data_segment.
populate control segment
perform build_control_segment.
populate trailer segment
perform build_trailer_segment.
create idoc
perform create_idocs.
perform bdc for transaction fb50
perform bdc_fb50.
**----
End-of-selection
**----
End-of-selection.
perform error_messages.
perform sucess_messages.
***********************************************************************
Top-Of-Page
***********************************************************************
Top-Of-Page.
Display the Standard Heading
PERFORM TOP_OF_PAGE.
&----
*& Form fill_it_bkpf_fmifiit
&----
subroutine to fill internal table it_bkpf_fmifiit
----
FORM fill_i_bkpf_fmifiit.
select fmifiit~fmbelnr
fmifiit~knbelnr
fmifiit~bus_area
fmifiit~objnrz
fmifiit~fonds
fmifiit~wrttp
fmifiit~trbtr
fmifiit~sgtxt
fmifiit~twaer
bkpf~budat
bkpf~blart
bkpf~bldat
into corresponding fields of table i_bkpf_fmifiit
from bkpf
join fmifiit
on bkpfbelnr = fmifiitknbelnr
where fmifiit~bus_area in s_b_area
and bkpf~budat in s_budat
and fmifiit~objnrz like c_orp
and ( fmifiitfonds like c_50p or fmifiitfonds like c_70p or
fmifiit~fonds like c_80p )
and ( fmifiitwrttp like c_54p or fmifiitwrttp like c_66p or
fmifiit~wrttp like c_95p ) .
ENDFORM. " fill_i_bkpf_fmifiit
&----
*& Form delete_it_bkpf_fmifiit
&----
subroutine to delete unwnated records from it_bkpf_fmifiit
----
FORM delete_i_bkpf_fmifiit.
delete records which have object number 9-14 as 999900
or object number third character is not alphabet
delete i_bkpf_fmifiit
where objnrz+2(1) NA sy-abcde
or objnrz+8(6) EQ c_999900.
loop at i_bkpf_fmifiit.
deletion indicator flag
clear f_delete.
find internal order number
i_bkpf_fmifiit-int_order = i_bkpf_fmifiit-objnrz+2(12).
select order type , funding source from aufk
select AUART zzfsc from aufk
into (aufk-auart , aufk-zzfsc)
up to 1 rows
where AUFNR = i_bkpf_fmifiit-int_order.
endselect.
if sy-subrc = 0.
delete the record if funding source is XX999999
if aufk-zzfsc CO C_XX999999.
delete i_bkpf_fmifiit.
f_delete = C_X.
endif.
endif.
if f_delete is initial.
modify the order type value with value from previous select
i_bkpf_fmifiit-auart = aufk-auart.
v_top_amount = i_bkpf_fmifiit-trbtr.
set amount field using over punch logic
CALL FUNCTION 'Z_SIGNED_NUMBER_CONV'
EXPORTING
GROSS_AMT = v_top_amount
IMPORTING
CONV_AMT = v_top_amount
EXCEPTIONS
INPUT_ERR = 1
WRONG_CHAR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
i_bkpf_fmifiit-trbtr = v_top_amount.
modify i_bkpf_fmifiit.
endif.
endloop.
ENDFORM. " delete_i_bkpf_fmifiit
&----
*& Form fill_control_record
&----
build outbound control information
----
FORM fill_control_record.
select control information from edp13
select * from edp13 into edp13
up to 1 rows
where mestyp eq c_message_type
and rcvprn = c_rcvprn
and idoctyp = c_idoc_type.
endselect.
i_edidc-direct = C_1. "Outbound
i_edidc-outmod = edp13-outmod. "Collective processing
i_edidc-rcvprn = edp13-rcvprn. "Partner number of receiver
i_edidc-rcvpor = edp13-rcvpor. "Receiver port
i_edidc-rcvprt = edp13-rcvprt. "Partner type of receiver
i_edidc-rcvpfc = edp13-rcvpfc. "Partner function of recipient
i_edidc-mestyp = edp13-mestyp. "Message type
i_edidc-mescod = edp13-mescod. "Message code
i_edidc-mesfct = edp13-mesfct. "Message function
i_edidc-test = edp13-test. "Test flag
i_edidc-idoctp = edp13-idoctyp. "Idoc Type
i_edidc-cimtyp = edp13-cimtyp. "Extension to Basic type
i_edidc-std = edp13-std. "EDI standard
i_edidc-stdvrs = edp13-stdvrs. "Version of EDI standard
i_edidc-stdmes = edp13-stdmes. "EDI message type
append i_edidc.
ENDFORM. " fill_control_record
&----
*& Form build_header_segment
&----
subroutine to build zibmishdr segment
----
FORM build_header_segment.
*header segment
X_Z1BMISHDR-hdr_ind = C_H.
X_Z1BMISHDR-ag_id = c_bmis.
X_Z1BMISHDR-trns_ag_ph = c_7177877901.
X_Z1BMISHDR-file_lbl = C_AFG840M01.
X_Z1BMISHDR-file_typ_cd = C_P.
X_Z1BMISHDR-creat_date = sy-datum. " format ccyymmdd
X_Z1BMISHDR-filler = C_FILLER.
assign segment name
i_edidd-segnam = C_HEADER_SEGMENT.
assign segment data
i_edidd-sdata = X_Z1BMISHDR.
append i_edidd.
clear i_edidd.
ENDFORM. " build_header_segment
&----
*& Form build_data_segment
&----
subroutine to build zibmisdata segment
----
FORM build_data_segment.
*main data segment
clear v_total_refs.
clear v_total_exps.
loop at i_bkpf_fmifiit.
if document type is KG(Vendor Credit Memo)
if i_bkpf_fmifiit-blart = C_KG.
X_Z1BMISDATA-maint_code = C_REF.
v_total_refs = v_total_refs + 1.
if document type is ZQ(Agencies not yet in SAP)
elseif i_bkpf_fmifiit-blart = C_ZQ .
if i_bkpf_fmifiit-sgtxt = c_460 or
i_bkpf_fmifiit-sgtxt = c_461 or
i_bkpf_fmifiit-sgtxt = c_462 or
i_bkpf_fmifiit-sgtxt = c_465 or
i_bkpf_fmifiit-sgtxt = c_470.
delete i_bkpf_fmifiit.
continue.
endif.
if document type is VT(Transfer posting)
elseif i_bkpf_fmifiit-blart = C_VT .
if i_bkpf_fmifiit-wrttp = C_66.
X_Z1BMISDATA-maint_code = C_EXP.
v_total_exps = v_total_exps + 1.
endif.
if document type is neither KG or ZQ
else .
if i_bkpf_fmifiit-wrttp = C_66 or i_bkpf_fmifiit-wrttp = C_95.
X_Z1BMISDATA-maint_code = C_REF.
v_total_refs = v_total_refs + 1.
endif.
if i_bkpf_fmifiit-wrttp = C_54 .
X_Z1BMISDATA-maint_code = C_EXP.
v_total_exps = v_total_exps + 1.
endif.
endif.
select grant department from cross walk table
zfi_t_busareacw
select ZDEPT from zfi_t_busareacw
into X_Z1BMISDATA-grant_dep
up to 1 rows
where GSBER = i_bkpf_fmifiit-bus_area.
endselect.
Assign internal order 2-6 char to grant number
X_Z1BMISDATA-grant_no = i_bkpf_fmifiit-int_order+1(5).
select fund type from fincode
select single type from FMFINCODE
into X_Z1BMISDATA-fund
where FIKRS = C_COPA
and FINCODE = i_bkpf_fmifiit-fonds.
depparment is same as grnat department
X_Z1BMISDATA-dept = X_Z1BMISDATA-grant_dep.
appropriarion is fonds 3-5 characters
X_Z1BMISDATA-approp = i_bkpf_fmifiit-fonds+2(3).
Year is fonds 6-7 characters
X_Z1BMISDATA-year = i_bkpf_fmifiit-fonds+5(2).
Ledger is fonds first character
X_Z1BMISDATA-ledger = i_bkpf_fmifiit-fonds+0(1).
document id is assigned with the SAP FI document number
X_Z1BMISDATA-doc_id = i_bkpf_fmifiit-knbelnr.
ICS posting date is assigned with SAP posting date
v_date = i_bkpf_fmifiit-budat.
v_mm = v_date+4(2).
v_dd = v_date+6(2).
v_yy = v_date+2(2).
concatenate v_mm v_dd v_yy into v_mmddyy.
X_Z1BMISDATA-ics_post_date = v_mmddyy.
if document type is KR , then ics posting date is
modified based on the payment terms
if i_bkpf_fmifiit-blart = C_KR.
select lfb1~ZTERM
into v_zterm
up to 1 rows
from FMIFIHD
join lfb1
on FMIFIHDlifnr = lfb1lifnr
where FMIFIHD~fmbelnr = i_bkpf_fmifiit-FMBELNR.
endselect.
if v_zterm NE C_P004.
v_zterm = v_zterm+1(2).
X_Z1BMISDATA-ics_post_date = i_bkpf_fmifiit-bldat + v_zterm.
endif.
endif.
X_Z1BMISDATA-amount = i_bkpf_fmifiit-trbtr.
find cuureny type and assign to v_currency
if v_currency is initial.
v_currency = i_bkpf_fmifiit-twaer.
endif.
find total expenditure amount
if X_Z1BMISDATA-maint_code = C_EXP.
v_total_exp_trbtr = v_total_exp_trbtr + X_Z1BMISDATA-amount.
find total refund amount
elseif X_Z1BMISDATA-maint_code = C_REF.
v_total_ref_trbtr = v_total_ref_trbtr + X_Z1BMISDATA-amount.
endif.
fill with blanks
X_Z1BMISDATA-filler = C_FILLER.
assign segment name
i_edidd-segnam = C_DATA_SEGMENT.
assign segment data
i_edidd-sdata = X_Z1BMISDATA.
append i_edidd.
clear i_edidd.
clear X_Z1BMISDATA.
endloop.
ENDFORM. " build_data_segment
&----
*& Form build_control_segment
&----
subroutine to build zibmiscon segment
----
FORM build_control_segment.
control segment
X_Z1BMISCON-maint_cd = C_CON.
assign total maintence records for expenditure
X_Z1BMISCON-tot_exp_no = v_total_exps.
assign total expenditure amount
X_Z1BMISCON-tot_exp_amt = v_total_exp_trbtr.
assign total maintence records for refund
X_Z1BMISCON-tot_ref_no = v_total_refs.
assign total refund amount
X_Z1BMISCON-tot_ref_amt = v_total_ref_trbtr.
v_date = sy-datum.
extract month from present date
X_Z1BMISCON-postdat_mm = v_date+4(2).
extract day from present date
X_Z1BMISCON-postdat_dd = v_date+6(2).
extract year from present date
X_Z1BMISCON-postdat_yy = v_date+2(2).
fiill with blanks
X_Z1BMISCON-filler = C_FILLER.
assign segment name
i_edidd-segnam = C_CONTROL_SEGMENT.
assign segment data
i_edidd-sdata = X_Z1BMISCON.
append i_edidd.
clear i_edidd.
ENDFORM. " build_control_segment
&----
*& Form build_trailer_segment
&----
subroutine to build zibmistrlr segment
----
FORM build_trailer_segment.
trailer segment
X_Z1BMISTRLR-trlr_ind = C_T.
X_Z1BMISTRLR-ag_id = C_BMIS.
X_Z1BMISTRLR-file_lbl = C_AFG840M01.
assign total data segment records
X_Z1BMISTRLR-file_tot_recs = v_total_records.
X_Z1BMISTRLR-filler = C_FILLER.
assign segment name
i_edidd-segnam = C_TRAILER_SEGMENT.
assign segment data
i_edidd-sdata = X_Z1BMISTRLR.
append i_edidd.
clear i_edidd.
ENDFORM. " build_trailer_segment
&----
*& Form create_idocs
&----
subroutine which creates IDOC document
----
FORM create_idocs.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = i_edidc
TABLES
COMMUNICATION_IDOC_CONTROL = i_edidc_comm
MASTER_IDOC_DATA = i_edidd
EXCEPTIONS
ERROR_IN_IDOC_CONTROL = 1
ERROR_WRITING_IDOC_STATUS = 2
ERROR_IN_IDOC_DATA = 3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 5
.
ENDFORM. " create_idocs
&----
*& Form bdc_fb50
&----
subroutine to call transaction fb50
----
FORM bdc_fb50.
sort the internal table by internal order and fund
sort i_bkpf_fmifiit by int_order fonds.
clear i_bkpf_fmifiit.
loop at i_bkpf_fmifiit.
clear x_bkpf_fmifiit.
X_bkpf_fmifiit = i_bkpf_fmifiit.
when a new fonds occurs sum
at new fonds.
sum.
v_amount = i_bkpf_fmifiit-trbtr.
i_bkpf_fmifiit = x_bkpf_fmifiit.
i_bkpf_fmifiit-trbtr = v_amount.
if v_amount is initial.
clear i_prog_msg-pmsg1.
i_prog_msg-pmsg1 = 'Record not created for internal order and
fund'(018).
concatenate i_bkpf_fmifiit-int_order space
c_and
i_bkpf_fmifiit-fonds
' as amount is zero '(019) into i_prog_msg-pmsg2
separated by space.
append i_prog_msg.
clear i_prog_msg.
delete i_bkpf_fmifiit
where int_order = i_bkpf_fmifiit-int_order
and fonds = i_bkpf_fmifiit-fonds.
else.
modify i_bkpf_fmifiit.
endif.
endat.
endloop.
delete the duplicates as we have already summed up them
delete adjacent duplicates from i_bkpf_fmifiit
comparing int_order fonds.
fill bdcdata internal table
perform fill_bdc_tab.
ENDFORM. " call_bdc_fb50
&----
*& Form fill_bdc_tab
&----
subroutine to fill bdcdata
----
form fill_bdc_tab.
clear i_bkpf_fmifiit.
loop at i_bkpf_fmifiit.
refresh i_bdcdata.
clear i_bdcdata.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
change the date format into ddmmyyyy
concatenate i_bkpf_fmifiit-Bldat+6(2)
i_bkpf_fmifiit-Bldat+4(2)
i_bkpf_fmifiit-Bldat+0(4)
into v_date.
fill bdcdata with document date
perform bdc_field using 'ACGL_HEAD-BLDAT'
v_date.
clear v_date.
fill bdcdata with currency type
perform bdc_field using 'ACGL_HEAD-WAERS'
i_bkpf_fmifiit-twaer.
concatenate i_bkpf_fmifiit-Budat+6(2)
i_bkpf_fmifiit-Budat+4(2)
i_bkpf_fmifiit-Budat+0(4)
into v_date.
fill bdcdata with posting date
perform bdc_field using 'ACGL_HEAD-BUDAT'
v_date.
clear v_date.
fill bdcdata with document type
perform bdc_field using 'ACGL_HEAD-BLART'
C_SB.
if order type starts with Y and end with 3 then account number
is 4000300 else 4000200
if i_bkpf_fmifiit-auart EQ C_Y3.
v_acc_number = C_4000300.
else.
v_acc_number = C_4000200.
endif.
fill bdcdata with g/l acct.num
perform bdc_field using 'ACGL_ITEM-HKONT(01)'
v_acc_number.
fill bdcdata with account type
perform bdc_field using 'ACGL_ITEM-SHKZG(01)'
c_h.
take off sign from amount
clear v_amount .
V_AMOUNT = ABS( i_bkpf_fmifiit-TRBTR ).
v_amountc = v_amount.
v_amount = abs( i_bkpf_fmifiit-TRBTR ).
write i_bkpf_fmifiit-TRBTR to v_amount no-sign.
fill bdcdata with amount
perform bdc_field using 'ACGL_ITEM-WRBTR(01)'
v_amountc.
fill bdcdata with taxcode
perform bdc_field using 'ACGL_ITEM-MWSKZ(01)'
c_C0.
select cost center from zfi_t_vfc
select zfcrf from zfi_t_vfc
into v_cost_center
up to 1 rows
where zzaufnr = i_bkpf_fmifiit-int_order.
endselect.
fill bdcdata with cost centre
perform bdc_field using 'ACGL_ITEM-KOSTL(01)'
v_cost_center.
fill bdcdata with int. order
perform bdc_field using 'ACGL_ITEM-AUFNR(01)'
i_bkpf_fmifiit-int_order.
fill bdcdata with fund
perform bdc_field using 'ACGL_ITEM-GEBER(01)'
i_bkpf_fmifiit-fonds.
fill bdcdata with data for debit account
V_acc_number = C_1300500.
fill bdcdata with g/l acct.num
perform bdc_field using 'ACGL_ITEM-HKONT(02)'
V_acc_number.
fill bdcdata with acct. type
perform bdc_field using 'ACGL_ITEM-SHKZG(02)'
c_S.
fill bdcdata with amount
perform bdc_field using 'ACGL_ITEM-WRBTR(02)'
v_amountc.
call transaction
perform bdc_transaction.
endloop.
endform.
&----
*& Form BDC_DYNPRO
&----
subroutine to start new screen
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR I_BDCDATA.
I_BDCDATA-PROGRAM = PROGRAM.
I_BDCDATA-DYNPRO = DYNPRO.
I_BDCDATA-DYNBEGIN = C_X.
APPEND I_BDCDATA.
clear i_bdcdata.
ENDFORM.
&----
*& Form BDC_FIELD
&----
subroutine to insert a field
----
FORM BDC_FIELD USING FNAM FVAL type any.
IF NOT FVAL IS INITIAL.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
clear i_bdcdata.
ENDIF.
ENDFORM.
&----
*& Form BDC_DYNPRO
&----
subroutine to start new transaction
----
FORM BDC_TRANSACTION .
REFRESH I_MESSTAB.
clear i_messtab.
CALL TRANSACTION C_TCODE USING I_BDCDATA
MODE C_MODE
UPDATE C_UPDATE
MESSAGES INTO I_MESSTAB.
if call transaction fails
IF SY-SUBRC <> 0.
find no.of lines in message table
DESCRIBE TABLE I_MESStab LINES v_LINES.
read the lasr message from table
READ TABLE I_MESStab INDEX v_LINES.
*-- Format the error message
PERFORM FORMAT_MESSAGE.
*-- Appending the error records into error table
v_line = v_line + 1.
I_ERROR_RECORDS-line = v_line.
I_ERROR_RECORDS-SMSG = V_MESSTXT.
APPEND I_ERROR_RECORDS.
CLEAR I_ERROR_RECORDS.
create new session
if f_group is initial.
clear v_date.
v_date = sy-datum - 1.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING CLIENT = SY-MANDT
GROUP = C_GROUP
USER = SY-uname
KEEP = 'X'
HOLDDATE = v_date
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11.
clear v_date.
if session created, set the flag f_group
if sy-subrc = 0.
f_group = C_X.
endif.
ENDIF.
if not f_group is initial.
CALL FUNCTION 'BDC_INSERT'
EXPORTING TCODE = C_TCODE
TABLES DYNPROTAB = I_BDCDATA.
endif.
REFRESH i_BDCDATA.
clear i_BDCDATA.
else.
find no.of lines in message table
DESCRIBE TABLE I_MESStab LINES v_LINES.
read the last message
READ TABLE I_MESStab INDEX v_LINES.
format the message
PERFORM FORMAT_MESSAGE.
extract document no. from formatted message
I_success_RECORDS-document_no = V_MESSTXT+9(10).
assign the internal order number
I_success_RECORDS-int_order = i_bkpf_fmifiit-int_order.
assign the fund
I_success_RECORDS-fonds = i_bkpf_fmifiit-fonds.
append records to success messages
APPEND I_success_RECORDS.
CLEAR I_success_RECORDS.
ENDIF.
ENDFORM.
&----
*& Form 09 FORMAT_MESSAGE
&----
----
This subroutine is used to format the error message
----
FORM FORMAT_MESSAGE.
CLEAR V_MESSTXT.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = 'E'
NO = I_MESSTAB-MSGNR
V1 = I_MESSTAB-MSGV1
V2 = I_MESSTAB-MSGV2
V3 = I_MESSTAB-MSGV3
V4 = I_MESSTAB-MSGV4
iMPORTING
MSG = V_MESSTXT.
ENDFORM. " FORMAT_MESSAGE
&----
*& Form sucess_messages
&----
subroutine to print sucess full messages
----
form sucess_messages.
f_flag = c_success.
start a new page
new-page.
ULINE.
change the color to col_normal
format color col_normal intensified on.
write : /01 sy-vline.
write : 02 'Total Maintenance Records for Expenditure'(006),
v_total_exps.
write : 165(01) sy-vline.
format color col_normal intensified off.
write : /01 sy-vline.
write : 02 'Total Amount for Expenditure '(007),v_total_exp_trbtr
currency v_currency, v_currency .
write : 165(01) sy-vline.
format color col_normal intensified on.
write : /01 sy-vline.
write : 02 'Total Maintenance Records for Refunds '(008),
v_total_refs.
write : 165(01) sy-vline.
format color col_normal intensified off.
write : /01 sy-vline.
write : 02 'Total Amount for Refunds '(009), v_total_ref_trbtr
currency v_currency, v_currency .
write : 165(01) sy-vline.
uline.
skip.
if there are any successful records
if not I_success_RECORDS[] is initial.
FORMAT COLOR COL_heading .
write /01(90) sy-uline.
WRITE :/1(01) SY-VLINE,
02(29) 'Document No'(010) ,
31(01) SY-VLINE,
32(29) 'Internal order'(011) ,
61(01) sy-vline,
62(28) 'Fund'(012),
90(01) sy-vline.
FORMAT COLOR off.
endif.
loop at sucessfull records messages
LOOP AT I_success_RECORDS.
PERFORM COLOR_SWAP.
WRITE :/1(01) SY-vLINE,
02(29) I_success_RECORDS-document_no ,
31(01) SY-VLINE,
32(29) I_success_RECORDS-int_order ,
61(01) sy-vline,
62(28) I_success_RECORDS-fonds,
90(01) sy-vline.
ENDLOOP.
if not I_success_RECORDS[] is initial.
write /01(90) sy-uline.
endif.
endform.
&----
*& Form error_messages
&----
subroutine to print error messages
----
form error_messages.
if there are any error records
IF NOT I_ERROR_RECORDS[] IS INITIAL.
f_flag = c_failure.
FORMAT COLOR COL_HEADING.
WRITE :/1(01) SY-VLINE,
02(10) 'Line .No'(003),
12(01) SY-VLINE,
13(51) 'Reason For Failure'(004),
64(01) sy-vline,
65(100) 'SAP Message'(005) ,
165(01) sy-vline.
FORMAT COLOR OFF.
loop at error records messages
LOOP AT I_ERROR_RECORDS.
PERFORM COLOR_SWAP.
WRITE :/1(01) SY-VLINE,
02(10) I_ERROR_RECORDS-line,
12(01) SY-VLINE,
13(51) I_ERROR_RECORDS-PMSG,
64(01) sy-vline,
65(100) I_ERROR_RECORDS-SMSG ,
165(01) sy-vline.
ENDLOOP.
if not I_prog_msg[] is initial.
DESCRIBE TABLE I_ERROR_RECORDS LINES v_LINES.
loop at program messages
LOOP AT I_prog_msg.
v_lines = v_lines + 1.
PERFORM COLOR_SWAP.
v_linc = v_lines.
WRITE :/1(01) SY-VLINE,
02(10) v_linc,
12(01) SY-VLINE,
13(51) I_prog_msg-PMSG1,
64(01) sy-vline,
65(100) space,
165(01) sy-vline.
PERFORM COLOR_SWAP.
WRITE :/1(01) SY-VLINE,
02(10) space,
12(01) SY-VLINE,
13(51) I_prog_msg-PMSG2,
64(01) sy-vline,
65(100) space,
165(01) sy-vline.
ENDLOOP.
endif.
endif.
IF NOT I_ERROR_RECORDS[] IS INITIAL.
uline.
endif.
endform.
&----
*& Form TOP_OF_PAGE
&----
Description : For Standard Top of Page
----
FORM TOP_OF_PAGE.
IF F_FLAG = C_SUCCESS.
V_TITLE = 'Success Records'(013).
ELSEIF F_FLAG = C_FAILURE.
V_TITLE = 'Error Records'(002).
ENDIF.
CALL FUNCTION 'Z_STANDARD_HEADER'
EXPORTING
ZTYPE = C_H
TITLE2 = 'GM Interface from SAP to CDS Refunds &
Expenditures'(015)
TITLE3 = V_TITLE.
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. " TOP_OF_PAGE
&----
*& Form COLOR_SWAP
&----
Description : To Swap the display colour.
----
FORM COLOR_SWAP.
if flag is set
if f_color eq c_x.
clear f_color.
switch off the intensity
format color col_normal intensified off.
else.
if flag is not set.
f_color = c_x.
switch on the intensity
format color col_normal intensified on.
endif.
ENDFORM. " COLOR_SWAP
Hope it helps.
Thanks
Suresh
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |