10-21-2008 9:56 AM
Hi Guys,
I need to create enhancement over standard sap functionality TCode: FP40.
As FP40 canu2019t be used for mass balance transfer, hence here I need to create one batch program which will transfer balances from all contract accounts (finalized and inactive) to another contract accounts (which are active) (and with same business partners) depends upon some u2018whereu2019 condition. (u2018Whereu2019 condition could be anything for example: u2018Number of Days after move out dateu2019)
Now once we got all source CAs (lets call them CA1) and destination CAs (i.e. CA2), we need to transfer balances.
Now my question is how to do that in the code? Here how I will call FP40 in the background?
10-21-2008 10:16 AM
Call this FM FKK_TRANSFER_ITEMS_XBLNR
FP40 t-code will call this FM to transfer the amount from one CA to another CA.
Regards,
Shiva Kumar
10-21-2008 10:16 AM
Call this FM FKK_TRANSFER_ITEMS_XBLNR
FP40 t-code will call this FM to transfer the amount from one CA to another CA.
Regards,
Shiva Kumar
10-21-2008 11:51 AM
It seems to be quite useful. FP40 is using same FM (but after lots of porcessing).
I found how to solve enter value in below parameters.
Tables:
T_FKKCL :
T_OPBEL_RANGE :
T_FIMSG:
but got confused with VTREF (contract). could you please help me with this parameter?
T_VTREF : I mean we can get old contract, but how to select new contract automatically? (remember I need to code this, no BDC). (in actual - FP40 user presses 'F4' key to select new contract in the pop screen)
if you have any suggestions for me, please guide me with it (for example. are there any other FMs I need to call/process?).
10-21-2008 1:19 PM
In our project we have done like this....Please see the code and let me know if you need any thing more...
One more thing "How to find new contract" -> This is your business scenario yaar.
In your functional design it will be there how to find new contract.(Example : Pick up the old contract business partner and find any other active contract and transfer the amount like this)
Posting Document Programmatically
To create a document programmatically we will use the following two Function modules.
u2022 FKK_CREATE_DOC
u2022 FKK_CREATE_DOC_AND_CLEAR
For FKK_CREATE_DOC: We need to populate the following tables/structures/parameters
u2022 I_FKKKO (Exporting)
u2022 I_FKKOPL_CF (Exporting - Value u2018Xu2019)
u2022 I_DIALOG (Exporting - Value u2018Xu2019)
u2022 T_FKKOP (Tables)
u2022 T_FKKOPK (Tables)
u2022 E_OPBEL (This is the importing/returning parameter)
In I_FKKKO populate the following fields:
u2022 FIKEY
u2022 APPLK
u2022 BLART
u2022 HERKF
u2022 WAERS
u2022 BLDAT
u2022 BUDAT
In I_FKKOP populate the following fields:
u2022 OPUPK
u2022 BUKRS
u2022 GPART
u2022 VTREF
u2022 VKONT
u2022 APPLK
u2022 BLART
u2022 HVORG
u2022 TVORG
u2022 FAEDN (Use FM u2018FKK_GET_DUE_DATEu2019 to determine Due Date)
u2022 KOFIZ
u2022 SPART
u2022 HKONT (Use FM u2018FKK_ACCOUNT_DETERMINEu2019 to determine G/L Acc)
u2022 MWSKZ
u2022 BLDAT
u2022 BUDAT
u2022 WAERS
u2022 BETRH
u2022 BETRW
Pass data to FM to determine G/L Account for FKKOP
ls_tfk033d-applk = <Constant u2018Ru2019>
ls_tfk033d-buber = <Constantu2019R000u2019>
ls_tfk033d-ktopl = <Constantu2019AGLu2019>
ls_tfk033d-key01 = <Company Code>
ls_tfk033d-key02 = <Division>
ls_tfk033d-key03 = <Account Determination ID>
ls_tfk033d-key04 = <Main Transaction>
FM to detrmine G/L Account
CALL FUNCTION 'FKK_ACCOUNT_DETERMINE'
EXPORTING
i_tfk033d = ls_tfk033d
IMPORTING
e_tfk033d = ls_tfk033d
EXCEPTIONS
error_in_input_data = 1
nothing_found = 2
OTHERS = 3.
Note: ls_tfk033d-fun01 will return the G/L Account
FM to determine due date
CALL FUNCTION 'FKK_GET_DUE_DATE'
EXPORTING
i_fkkko = ls_fkkko
i_fkkop = ls_fkkop
IMPORTING
e_faedn = lv_faedn.
Note: lv_faedn will return the Due Date.
In I_FKKOPK populate the following fields:
Here we need to populate 2 items; the amount field will be always the negative of the amount that has been passed to FKKOP.
First Line Item;
u2022 MANDT
u2022 FIKEY
u2022 OPUPK
u2022 BUKRS
u2022 HKONT (Use FM u2018CALCULATE_TAX_FROM_NET_AMOUNTu2019 to determine G/L Account)
u2022 MWSKZ
u2022 SBASH (Same as BETRH)
u2022 SBASW (Same as BETRW)
Here the G/L account is for GST.
FM to Get the TAX G/L Account
CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT'
EXPORTING
i_bukrs = <Company Code>
i_mwskz = <Tax Code>
i_waers = <Constant u2018AUDu2019>
i_wrbtr = <Open Amount>
TABLES
t_mwdat = lt_mwdat
EXCEPTIONS
bukrs_not_found = 1
country_not_found = 2
mwskz_not_defined = 3
mwskz_not_valid = 4
ktosl_not_found = 5
kalsm_not_found = 6
parameter_error = 7
knumh_not_found = 8
kschl_not_found = 9
unknown_error = 10
account_not_found = 11
txjcd_not_valid = 12
OTHERS = 13.
IF sy-subrc <> 0 OR lt_mwdat[] IS INITIAL.
Display message
ENDIF.
Populate G/L Account ID in FKKOPK
READ TABLE lt_mwdat INTO ls_mwdat INDEX 1.
IF sy-subrc = 0.
lv_hkont = ls_mwdat-hkont. u201CThis is the G/L Account Number.
ENDIF.
Second Line Item;
u2022 MANDT
u2022 FIKEY
u2022 OPUPK
u2022 BUKRS
u2022 HKONT (Use FM u2018FKK_ACCOUNT_DETERMINEu2019 to determine G/L Acc)
u2022 MWSKZ
u2022 BETRH
u2022 BETRW
Here the G/L Account is development specific. You can cross check this G/L Account in table SKAT.
Pass data to FM to determine G/L Account for FKKOPK -- 2nd Item in FKKOPK
ls_tfk033d-applk = <Constant u2018Ru2019>
ls_tfk033d-buber = <Constantu2019R001u2019>
ls_tfk033d-ktopl = <Constantu2019AGLu2019>
ls_tfk033d-key01 = <Company Code>
ls_tfk033d-key02 = <Division>
ls_tfk033d-key03 = <Account Determination ID>
ls_tfk033d-key04 = <Main Transaction>
ls_tfk033d-key05 = <Sub Transaction>
FM to detrmine G/L Account
CALL FUNCTION 'FKK_ACCOUNT_DETERMINE'
EXPORTING
i_tfk033d = ls_tfk033d
IMPORTING
e_tfk033d = ls_tfk033d
EXCEPTIONS
error_in_input_data = 1
nothing_found = 2
OTHERS = 3.
Note: ls_tfk033d-fun01 will return the G/L Account
Finally call the FM u2018FKK_CREATE_DOCu2019 & pass the above mentioned structures/tables to create the document. Remember to call the FM u2018BAPI_TRANSACTION_COMMITu2019 to save the created document.
Post the document
CALL FUNCTION 'FKK_CREATE_DOC_AND_CLEAR'
EXPORTING
i_fkkko = ls_fkkko
i_fkkopl_cf = u2018Xu2019
i_dialog = u2018Xu2019
IMPORTING
e_opbel = <This will return the new document>
TABLES
t_fkkop = lt_fkkop
t_fkkopk = lt_fkkopk.
FM to Save the transaction.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = u2018Xu2019.
For FKK_CREATE_DOC_AND_CLEAR: We need to populate the save tables/structures/parameters those we have populated for u2018FKK_CREATE_DOCu2019. But along with the above fields we need to populate one more tables parameter u2018T_FKKCLu2019.
To populate this call the FM u2018FKK_OPEN_ITEM_SELECTu2019. This will populate the FKKCL internal table.
Pass data to FM
MOVE: u20180001u2019 TO lt_seltab-selnr,
u2018VTREFu2019 TO lt_seltab-selfn,
lv_vtref TO lt_seltab-selcu.
APPEND lt_seltab.
CLEAR: lt_seltab.
Find open items for the contract being processed. If none found, no
further action required.
CALL FUNCTION 'FKK_OPEN_ITEM_SELECT'
EXPORTING
i_applk = u2018Ru2019
TABLES
t_seltab = lt_seltab
t_fkkcl = lt_fkkcl
EXCEPTIONS
concurrent_clearing = 1
payment_orders = 2
OTHERS = 3.
Note: lv_vtref is the reference contract number.
Finally call the FM u2018FKK_CREATE_DOCu2019 & pass the above mentioned structures/tables to create the document. Remember to call the FM u2018BAPI_TRANSACTION_COMMITu2019 to save the created document.
Post the document
CALL FUNCTION 'FKK_CREATE_DOC_AND_CLEAR'
EXPORTING
i_fkkko = ls_fkkko
i_fkkopl_cf = u2018Xu2019
i_dialog = u2018Xu2019
IMPORTING
e_opbel = <This will return the new document>
TABLES
t_fkkop = lt_fkkop
t_fkkopk = lt_fkkopk
t_fkkcl = lt_fkkcl.
FM to Save the transaction.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = u2018Xu2019.
Regards,
Shiva Kumar
10-21-2008 3:54 PM
Hi Siva, it seems that there is one more solution hidden in your code: thanks
so let me explain you...
I need to convert stat document into real document by using dunning user exit 350 (FKK_SAMPLE_0350).
Step 1:
Select Single FUN01 FUN02 from TFK033D into ls_real_trans where APPLK (Application area) = u2018Ru2019, BUBER (Posting area) = u20181010u2019, Key01 = u2018Gu2019, Key02 = FKKOP u2013HVORG (main of stat doc), Key03 = FKKOP-TVORG (sub of stat doc). (This will help us to find relationship between stat and real document).
Step 2:
Select single OPBEL from DFKKOP into ls_real_doc where HVORG = ls_real_trans- HVORG and TVORG = ls_real_trans- TVORG. (Now we have info of real doc which we are going to post).
Step 3:
For FKK_CREATE_DOC_AND_CLEAR: We need to populate the save tables/structures/parameters those we have populated for u2018FKK_CREATE_DOCu2019. But along with the above fields we need to populate one more table parameter u2018T_FKKCLu2019.
CALL FUNCTION 'FKK_OPEN_ITEM_SELECT' to populate T_FKKCL.
Step 4:
CALL FUNCTION 'FKK_CREATE_DOC_AND_CLEARu2019.
This will clear old statistical document will post new one.
Step 5:
CALL FUNCTION 'FKK_CREATE_DOC'.
This will post new real document.
Step 6:
To Save the transaction:
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
Any comments for above six steps. I know you can help me :-). If I am doing anything wrong or missing any step do help me.
I am rookie in this area so it would be of great help if you explain in steps.
Thanks
05-07-2010 9:27 PM
Hi
I have one question FI-CA
I must transfert items existing in the clarification list to an another account general. When this items will be in the new account, one OD will be erased them
Is a standard transaction exists to do this operation of transfer (for example an FP40 specially for mass transfer items for the clarification list) ?
Thanks for your help
Regards
Ficachu