01-23-2008 6:37 AM
Hi!!
i am using two database tables cobk & coep & two Custom tables repost1 & repost2.
extracting the data from cobk,coep & repost1
&
UPDATING an interanal table of repost2 i.e. itab_repost2.
now passing the data from itab_repost2 to header & item of BAPI.
i.e.
Postings are created using BAPI_ACC_MANUAL_ALLOC_POST.
Now
In case of error a batch input file is created .
Please help me in creating the batch input file.
My Question is how to create this batch input file in case of errors returned by bapi return parameter......
please reply soon....
Amit.
01-24-2008 10:30 AM
STOP, i think there is a misunderstanding, what kind of document are you posting?
financial document, Manual Reposting of Costs, Manual Reposting of Revenues, Activity Allocation ?
Regards
01-23-2008 11:02 AM
Create a recording, generate some sample code and use this code in your own program.
transaction SM35
Menu "go to recording"
push button "create new recording"
Fill in XK01 and start filling the screens as if you would post data manually.
Once a recording was created, you can generate an abap program automatically: position on your recording and press the "create program" button...
01-23-2008 12:22 PM
please help..........
actually the above reply is not able to solve the query.
thank you
amit.
01-23-2008 12:30 PM
When the call of the BAPI returns an error, build the BDC for FD01 with function modules like
POSTING_INTERFACE_START (first)
POSTING_INTERFACE_DOCUMENT
POSTING_INTERFACE_END (last)
or build the batch input file yourself the traditional way (SHDB, etc.)
As BAPI and BDC are too different interface tools, i don't think there is a program to convert the parameter from one to the old one.
Regards
01-23-2008 1:00 PM
Hi!!
All these three function modules ae needed??
& have to use one by one??
& after doing this how to view the file & where it will be generated??
can u guide me with a detailed procedure.
Thank You
amit..
01-23-2008 1:28 PM
The modules POSTING_INTERFACE_START and POSTING_INTERFACE_END will only be called once, and POSTING_INTERFACE_DOCUMENT once per document in error.
First module can be used like BDC_OPEN
CALL FUNCTION 'POSTING_INTERFACE_START'
EXPORTING
i_function = 'B'
i_group = <group>
i_user = <user>
i_xbdcc = 'X'
i_keep = <keep>.
CALL FUNCTION 'POSTING_INTERFACE_END'.
(No parameters, easy)
Posting documents
CALL FUNCTION 'POSTING_INTERFACE_DOCUMENT'
EXPORTING
i_tcode = 'FB01'
IMPORTING
e_subrc = subrc
e_msgid = msgid
e_msgty = msgty
e_msgno = msgno
e_msgv1 = msgv1
e_msgv2 = msgv2
e_msgv3 = msgv3
e_msgv4 = msgv4
TABLES
t_ftpost = ftpost
t_fttax = fttax
t_blntab = xblntab
FTPOST internal table begins with K-type record (t_ftpost-stype = 'K') for the document header and P-type records for the items with a count to destinct between subsequent items
Sample :
K |001 |BKPF-BLDAT |23.01.2008 <
K |001 |BKPF-BKTXT |A <
K |001 |BKPF-BUDAT |23.01.2008 <
K |001 |BKPF-BUKRS |XXX <
K |001 |BKPF-WAERS |EUR <
K |001 |BKPF-BLART |SA <
P |001 |BSEG-SGTXT |FGESP PROPRI <
P |001 |RF05A-NEWBS |40 <
P |001 |RF05A-NEWKO |613504 <
P |001 |BSEG-MWSKZ |P0 <
P |001 |BSEG-WRBTR |23000 <
P |001 |BSEG-ZUONR |LFPB <
P |001 |COBL-PS_PSP_PNR |0 FGESP PR <
P |002 |BSEG-SGTXT |FGMOH CHARTER <
P |002 |RF05A-NEWBS |40 <
P |002 |RF05A-NEWKO |606160 <
P |002 |BSEG-MWSKZ |P0 <
P |002 |BSEG-WRBTR |20000 <
P |002 |BSEG-ZUONR |LFPB <
P |002 |COBL-PS_PSP_PNR |FGMOH CHARTER <
Regards
01-23-2008 1:38 PM
Thank YOU !!
please be in tact. I will try the things u have told & if any probs will get back to u..
thank YOU
amit
01-23-2008 1:56 PM
Hi!!
please answer the following questions:
in i_group can i write any group name?
i_user = sy-user
i_keep = keep
in importing i am copying the same
e_subrc = subrc
e_msgid = msgid
e_msgty = msgty
e_msgno = msgno
e_msgv1 = msgv1
e_msgv2 = msgv2
e_msgv3 = msgv3
e_msgv4 = msgv4
in Tables tab i can only provide values to
ftpost.
I don't know what to give to fttax & xblntab.
& one more thing where to check this batch input file.
Actually i am very new to abap & in my first project i m given this work to do.
please guide me......
I will be highly greatful to u
Thank You.
amit.
01-23-2008 3:34 PM
i_group : Give the name you want the batch input file to appear under SM35
As you come from CO (cobk+coep) you won't have any VAT (i hope) so just find a VAT code suitable for the account (collected or deductive) with a zero rate and provide an empty fttax (This table is only useful for importing vendor invoices when you don't want SAP to calculate the VAT)
xblntab is an exported table, the function module can be interactively called, in this case this table will contain the document generated numbers.
Regards
01-24-2008 7:21 AM
hi!!
Actually i misunderstood it. I need to ask that how to populate ftpost in tables tab & How to get this VAT NO & where to provide it??
I have populated XBLNTAB with document number & company code.
Please reply soon....
thank you
amit.
01-24-2008 7:48 AM
Don't fill XBLNTAB, the function module fill and export this table when option "call transaction" is called.
To get a VAT code with rate 0, ask your FI consultant, it depends on your customizing. (You may create a parameter of your program)
You need to map FTPOST from the data you used in the BAPI. mapping header and item fields to the table when they are not initial, and incrementing a counter between each intem or document header. (Re-look at the sample result provided)
Regards.
01-24-2008 9:26 AM
hi!!
first of all i would like to thank you very much for all ur help.
actually i have created internal table for all these three tables.
gt_ftpost type standard table of ftpost,
gt_xblntab type standard table of blntab,
gt_fttax type standard table of fttax.
is this right as i am pass these in tables field??..
Q: so now the only table i have to populate is gt_ftpost with the doc_header & item fields??
And i didn't crated any parameter for vat code so IS IT NOT NEEDED??
reply soon ..
thank you
amit.
Edited by: Amit Kumar Singh on Jan 24, 2008 10:27 AM
01-24-2008 9:49 AM
Yes
> DATA: gt_ftpost type standard table of ftpost,
> gt_xblntab type standard table of blntab,
> gt_fttax type standard table of fttax.
>
>CALL FUNCTION 'POSTING_INTERFACE_DOCUMENT'
> EXPORTING
> i_tcode = 'FB01'
> IMPORTING
> e_subrc = subrc
> e_msgid = msgid
> e_msgty = msgty
> e_msgno = msgno
> e_msgv1 = msgv1
> e_msgv2 = msgv2
> e_msgv3 = msgv3
> e_msgv4 = msgv4
> TABLES
> t_ftpost = gt_ftpost " filled with field from header./item
> t_fttax = gt_fttax " empty
> t_blntab = gt_xblntab "empty.
VAT code (BSEG-MWSKZ) can or cannot be required (in ftpost) , it depends on the customization of your system and of the tax category of account in Company (Transaction FSS0, field SKB1-MWSKZ)
Regards
01-24-2008 9:58 AM
hi!!
while populating document header & item before passing to bapi.
header i passed these fields
KOKRS
BELNR
PERIO
TCURR
TXT
to item i passed these fields
TCURR
KSTAR
BUKRS
PBUKRS
SKST
RKST
now while trying to populate data to ftpost
KOKRS & BELNR FOR HEADER IN BSEG
&
KSTAR & BUKRS FOR ITEM IN BSEG
in bkpf , I found none of the fields & in RF05A i found only bukrs by the name agbuk.
which one to populate.
thank you
amit.
01-24-2008 10:07 AM
BKPF
KOKRS BKPF-BUKRS
BELNR Only give this field if you use external number for FI (usually don't pass this field)
PERIO Give BKPF-BUDAT and BKPF-BLDAT (dates) AND BKPF-MONAT (FI period)
TCURR Give currency BKPF-WAERS and rate BKPF-KURSF
TXT BKPF-BKTXT
BSEG
KSTAR RF05A-NEWKO account associated with Cost element (same value)
RF05A-NEWBS, 40/50 depending on sign
Regards
01-24-2008 10:11 AM
01-24-2008 10:15 AM
aND I FOUND ONLY FOUR FIELDS
BELNR
BUKRS
KOKRS
KSTAR
so should populate only these four fields in gt_ftpost..
01-24-2008 10:15 AM
01-24-2008 10:28 AM
DATA: subrc LIKE sy-subrc,
msgid LIKE sy-msgid,
msgty LIKE sy-msgty,
msgno LIKE sy-msgno,
msgv1 LIKE sy-msgv1,
msgv2 LIKE sy-msgv2,
msgv3 LIKE sy-msgv3,
msgv4 LIKE sy-msgv4.
DATA: groupname LIKE apqi-groupid.
function LIKE rfipi-funct,
xbdcc LIKE rfipi-xbdcc.
*POPULATE DATA INTO GT_FTPOST.
READ TABLE gt_yrepost2_test1 INDEX 1.
gt_ftpost-stype = 'K'. "K:HEADER
gt_ftpost-count = '1'.
gt_ftpost-fnam = 'BSEG-KOKRS'.
gt_ftpost-fval = gt_yrepost2_test1-kokrs.
APPEND gt_ftpost.
gt_ftpost-stype = 'K'.
gt_ftpost-count = '1'.
gt_ftpost-fnam = 'BSEG-BELNR'.
gt_ftpost-fval = gt_yrepost2_test1-belnr.
APPEND gt_ftpost.
gt_ftpost-stype = 'P'. " P: Item
gt_ftpost-count = '1'.
gt_ftpost-fnam = 'BSEG-KSTAR'.
gt_ftpost-fval = gt_yrepost2_test1-kstar.
APPEND gt_ftpost.
gt_ftpost-stype = 'P'.
gt_ftpost-count = '1'.
gt_ftpost-fnam = 'BSEG-KSTAR'.
gt_ftpost-fval = gt_yrepost2_test1-kstar.
APPEND gt_ftpost.
CALL FUNCTION 'POSTING_INTERFACE_START'
EXPORTING
I_CLIENT = SY-MANDT
i_function = 'B'
i_group = groupname
I_HOLDDATE = ' '
i_keep = 'X'
I_MODE = 'N'
I_UPDATE = 'S'
i_user = sy-uname
i_xbdcc = ''
EXCEPTIONS
CLIENT_INCORRECT = 1
FUNCTION_INVALID = 2
GROUP_NAME_MISSING = 3
MODE_INVALID = 4
UPDATE_INVALID = 5
OTHERS = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'POSTING_INTERFACE_DOCUMENT'
EXPORTING
i_tcode = 'FB01'
I_SGFUNCT = ' '
I_NO_AUTH = ' '
IMPORTING
e_msgid = msgid
e_msgno = msgno
e_msgty = msgty
e_msgv1 = msgv1
e_msgv2 = msgv2
e_msgv3 = msgv3
e_msgv4 = msgv4
e_subrc = subrc
TABLES
t_blntab = gt_xblntab
t_ftpost = gt_ftpost
t_fttax = gt_fttax
EXCEPTIONS
ACCOUNT_MISSING = 1
COMPANY_CODE_MISSING = 2
POSTING_KEY_INVALID = 3
POSTING_KEY_MISSING = 4
RECORD_TYPE_INVALID = 5
TRANSACTION_CODE_INVALID = 6
AMOUNT_FORMAT_ERROR = 7
TOO_MANY_LINE_ITEMS = 8
COMPANY_CODE_INVALID = 9
SCREEN_NOT_FOUND = 10
NO_AUTHORIZATION = 11
OTHERS = 12
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'POSTING_INTERFACE_END'
EXPORTING
I_BDCIMMED = ' '
I_BDCSTRTDT = NO_DATE
I_BDCSTRTTM = NO_TIME
EXCEPTIONS
SESSION_NOT_PROCESSABLE = 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. " BATCH_INPUT_FILE
01-24-2008 10:32 AM
01-24-2008 10:30 AM
STOP, i think there is a misunderstanding, what kind of document are you posting?
financial document, Manual Reposting of Costs, Manual Reposting of Revenues, Activity Allocation ?
Regards
01-24-2008 10:37 AM
OK!!
I repeat actually the whole problem is that
i have custom table yrepost2.
having fields:
kokrs
belnr
buzei
perio
amount
kstar
bukrs
pbukrs
tcurr
skst
rkst
rkstar
txt
I have to pass this to BAPI: bapi_acc_manual_alloc_post.
then if bapi returns the error i have to write records to batch input file.
I don't know what kind of posting this is??
Thank You.
01-24-2008 10:52 AM
Can you give the data element of the database table.
To create a posting you need
Header
- header info : dates/period, controlling area
Item
- a cost element (KSTAR)
- two objects, sender and receiver (eg: cost center, order, WBS)
- amount, currency (or default from controling area),
Are skst and rkst cost centers ?
If yes the transaction used in batch input will be KB11 (as KB11N is enjoy and may so be unelligible for BTC)
Regards
01-24-2008 10:58 AM
skst : sending cost centre
rkst : receiving cost centre
rkstar : reposting cost element
Amount is the value.
tcurr is transaction currency.
transaction used will kb15n.
Thank You.
01-24-2008 11:03 AM
As KB15N is enjoy, use KB15 the old way, builidng a BTC with "traditional" include bdcrecx1
perform open_group.
perform bdc_dynpro using 'SAPMK23B' '1001'.
perform bdc_field using 'BDC_CURSOR'
'COBK-VARNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'COBK-BLDAT'
'24.01.2008'. " << Here put the date
perform bdc_field using 'COBK-BUDAT'
'24.01.2008'. " << Date
perform bdc_field using 'COBK-KOKRS'
'DFS'. " << controling area
perform bdc_field using 'COBK-VARNR'
'SAP01'. " standard variant for cost center
perform bdc_dynpro using 'SAPMK23B' '1111'.
perform bdc_field using 'BDC_CURSOR'
'RK23B-IVBSU(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RK23A-TWAER'
'EUR'. " << currency
perform bdc_field using 'RK23B-SKOST(01)'
'C953103000'. " << Sender cost center
perform bdc_field using 'RK23B-EKOST(01)'
'C953007900'. " << Receiver Cost Center
perform bdc_field using 'RK23B-KSTAR(01)'
'603310'. " << Cost element
perform bdc_field using 'RK23B-IKPSU(01)'
' 100'. << Amount in currency
perform bdc_dynpro using 'SAPMK23B' '1111'.
perform bdc_field using 'BDC_CURSOR'
'RK23B-IVBSU(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_transaction using 'KB15'.
Regards
Edited by: Raymond Giuseppi on Jan 24, 2008 12:50 PM
01-24-2008 11:27 AM
Hi !!
Extreamly sorry for bothering u more than enough
But i want u to explain all this to me......
Please if u can!!
Thank You
amit.
01-24-2008 11:54 AM
Just provide the parameter used in FORM OPEN_GROUP to declare creation of a batch input file.
Replace constants where i put a comment beginning with << by values from your structure.
Don't' forget to convert fields value to CHAR for btach input, use WRITE TO work fields.
The standard include contains PARAMETERS fields, if you don't want those, copy the other definition and forms to your program.
Regards
01-25-2008 5:41 AM
I have copied the code & Replaced constants where u put a comment beginning with << by values from my structure.
PERFORM bdc_field USING 'COBK-KOKRS'
'GT_REPOST-KOKRS'. " << controling area.
is this right??
where should i declare for form for these performs & what should i write there.......??
where to provide the parameter used in FORM OPEN_GROUP to declare creation of a batch input file & what to provide??
actually what should i write in form OPEN_GROUP.
THANK YOU
AMIT.
01-25-2008 7:22 AM
BDC_FIELD
Use the value of the fields, not their name
PERFORM bdc_field USING 'COBK-KOKRS'
GT_REPOST-KOKRS. " << controlling area.
For numerical fields, amount, date or field with conversion exit write them to a character field before calling bdc_fields.
OPEN_GROUP.
For definition of parameters, look at BDCRECX1
SESSION = 'X'. to create batch input file
CLIENT = SY-MANDT. " default
GROUP = <group_name>.
USER = SY-UNAME. " default
KEEP = 'X'. " X if you want to keep the bdc after execution, you can remove it in production, keep it in dev
HOLDDATE = initial, else Session locked until specified date
Look at function module BDC_OPEN_GROUP for documentation
Regards
01-28-2008 9:33 AM
Thank You very much ................
I am now able to generate batch input,
Thanks & regards
Amit.