08-04-2014 4:55 PM
Hi Experts,
I'm very new to ABAP (and I like it ).
Below my first steps in ABAP:
DATA : answer TYPE BAPIRET2.
DATA : mmarket TYPE BAPI2042_MAINTAIN_MM.
mmarket-transaction_type = '100'.
mmarket-partner = '10000'.
mmarket-start_term = '04082014'.
mmarket-end_term = '04082014'.
mmarket-amount = 1000000.
mmarket-currency = 'EUR'.
mmarket-interest_rate = '1.37'.
CALL FUNCTION 'BAPI_FTR_CREATEFROMDATA'
EXPORTING
MONEYMARKET = mmarket
* FOREIGNEXCHANGE =
COMPANYCODE = 'DE01'
PRODUCTTYPE = '510'
IMPORTING
RETURN = answer
* TRANSACTION =
* COMPANYCODE =
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
WRITE : / 'Fehler im System'.
ENDIF.
WRITE : / answer-message.
WRITE : / answer-type.
WRITE : / answer-id.
WRITE : / answer-number.
WRITE : / answer-log_no.
WRITE : / answer-log_msg_no.
WRITE : / answer-parameter.
WRITE : / answer-row.
WRITE : / answer-field.
I want to call the BAPI and fill in the form.
answer-message and answer-type is empty. It seems that there is no error but shouldn't I get a success message like "S" in Type?
It is possible that the valuation area can not be filled with this BAPI?
Thanks for your help.
Xaavian
08-06-2014 8:07 AM
Hello everyone,
yesterday I found the solution .
Sharmila was right, a parameter was missing. Now I assigned the gen. valuation class to a producttype/companycode via spro SAPL0GH2 and it works like a charm .
Thank you all so much!
Faruq
08-04-2014 5:28 PM
Reading the help on the FM (specifically the return parameter) will answer your question.
"If an error occurs, this parameter contains the error number and text once the method returns to the program calling it up. If there are no errors, the parameter is left blank."
Ergo, a blank return structure indicates a successful call.
Regards,
Aaron
08-04-2014 6:23 PM
Hi Faruq,
Are you able to create the document successfully using this BAPI? Yes, you should get success message, message ID, type, number etc. in the return structure. Once the return type is 'S', call BAPI: BAPI_TRANSACTION_COMMIT to complete the transaction.
Thanks,
Shreekant
08-05-2014 7:46 AM
Hi Shreekant,
currently I'm not able to create the document successfully. Is there any parameter missing?
The code seems to be correct.
Thanks,
Faruq
08-05-2014 8:17 AM
Hello Faruq,
Thanks
08-05-2014 8:23 AM
Hi Learner,
DATA : answer TYPE BAPIRET2.
...
CALL FUNCTION 'BAPI_FTR_CREATEFROMDATA'
EXPORTING
MONEYMARKET = mmarket
COMPANYCODE = 'DE01'
PRODUCTTYPE = '510'
IMPORTING
RETURN = answer
EXCEPTIONS
ERROR = 1
OTHERS = 2.
RETURN is filled. When I call the FM with an missing attribute it throws an error 'E'.
Also the SY-SUBRC returns 0.
Thanks,
Faruq
08-05-2014 8:36 AM
Hello Faruq,
Please share the message number and message class.
Thanks
08-05-2014 8:42 AM
Hello Learner,
could you please tell me exactly what you want me to share? (I'm very new to ABAP)
I really do not know what to share.
Thanks,
Faruq
08-05-2014 8:56 AM
08-05-2014 9:06 AM
Hi Farug,
If you look inside the BAPI , you can see BAPI will return only errors( E or A type), if you getting return blank means BAPI call is successful . After return is blank then call BAPI_TRANSACTION_COMMIT.
As learner suggested, keep break point at end of BAPI, Check l_tab_return contains any warning or information messages.
Thanks & Regards,
Arun
08-05-2014 9:16 AM
Hi Arun,
l_tab_return does not contain any messages or warnings. It is empty.
BAPI_TRANSACTION_COMMIT should create a new contract but it does not.
IF answer-type IS INITIAL.
DATA : returncode TYPE BAPIRET2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
IMPORTING
RETURN = returncode.
WRITE : / returncode-message.
WRITE : / returncode-type.
WRITE : / returncode-id.
The contents of answer are:
000
000000
0
Thanks,
Faruq
08-05-2014 9:32 AM
Hi Faruq,
Certain BAPIs return only Error messages. If there is no error, then the return structure is initial i.e., blank.
In 'BAPI_FTR_CREATEFROMDATA' , only error messages are returned. So, instead of checking for the SY_SUBRC value after the Function call, you could check the return structure.
For Eg.
IF answer IS NOT INITIAL. (or IF answer-type = 'E'.)
* Implement suitable error handling here
WRITE : / 'Fehler im System'.
EXIT.
ENDIF.
Then Call the BAPI_TRANSACTION_COMMIT, if there are no errors.
Hope, this helps.
08-05-2014 9:44 AM
Faruq,
If return or l_tab_return is empty, then your document will be created successfully. Check the corresponding transaction number. For that you need to use Importing parameter TRANSACTION in your BAPI call.
CALL FUNCTION 'BAPI_FTR_CREATEFROMDATA'
EXPORTING
MONEYMARKET = mmarket
COMPANYCODE = 'DE01'
PRODUCTTYPE = '510'
IMPORTING
RETURN = answer
TRANSACTION = ls_transaction
EXCEPTIONS
ERROR = 1
OTHERS = 2.
08-05-2014 10:30 AM
Hi Sharmila,
thanks for your answer.
I tried your suggestion:
DATA : ls_transaction TYPE BAPI2042-TRANSACTION.
CALL FUNCTION 'BAPI_FTR_CREATEFROMDATA'
EXPORTING
MONEYMARKET = mmarket
* FOREIGNEXCHANGE =
COMPANYCODE = 'DE01'
PRODUCTTYPE = '510'
IMPORTING
RETURN = answer
TRANSACTION = ls_transaction
* COMPANYCODE =
EXCEPTIONS
ERROR = 1
OTHERS = 2.
WRITE : / ls_transaction.
ls_transaction is empty.
The whole code is:
DATA : answer TYPE BAPIRET2.
DATA : mmarket TYPE BAPI2042_MAINTAIN_MM.
DATA : ls_transaction TYPE BAPI2042-TRANSACTION.
DATA : ls_companycode TYPE BAPI2042-COMPANY_CODE.
DATA : returncode TYPE BAPIRET2.
mmarket-transaction_type = '100'.
mmarket-partner = '10000'.
mmarket-start_term = '05082014'.
mmarket-end_term = '05102014'.
mmarket-amount = 1000000.
mmarket-currency = 'EUR'.
mmarket-currency_iso = 'EUR'.
mmarket-interest_rate = '1.37'.
mmarket-calculate_method = 2.
mmarket-trader = 'Alavi'.
CALL FUNCTION 'BAPI_FTR_CREATEFROMDATA'
EXPORTING
MONEYMARKET = mmarket
* FOREIGNEXCHANGE =
COMPANYCODE = 'DE01'
PRODUCTTYPE = '510'
IMPORTING
RETURN = answer
TRANSACTION = ls_transaction
COMPANYCODE = ls_companycode
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
WRITE : / 'Fehler im System'.
ENDIF.
WRITE : / answer-message.
WRITE : / answer-type.
WRITE : / answer-id.
WRITE : / ls_transaction.
WRITE : / ls_companycode.
IF answer-type IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
IMPORTING
RETURN = returncode.
WRITE : / returncode-message.
WRITE : / returncode-type.
WRITE : / returncode-id.
ENDIF.
Thanks,
Faruq
08-05-2014 10:43 AM
Faruq,
Internal date format is YYYYMMDD. So, your dates should be
mmarket-start_term = '20140804'. (Whatever is the date, give it in YYYYMMDD format)
mmarket-end_term = '20140804'.
Change the date values and try.
08-05-2014 10:46 AM
08-05-2014 10:47 AM
Hello Faruq.
Add FM to add leading zeroes to mmarket-partner.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = mmarket-partner
IMPORTING
OUTPUT = mmarket-partner.
08-05-2014 11:32 AM
The BAPI_FTR_FTD_CREATE returns following:
l_tab_return:
ftr_gui 141: valuation area needs to be filled
ftr_trd 031: Geschäft DE01 \INTERN\ ist keine 'Allg. Bewertungsklasse' zugeordnet (no valuation area assigned)
Now I need to assign the valuation area but there is no parameter for the valuation area.
Thanks,
Faruq
08-05-2014 11:51 AM
There is no valuation area assigned to the company code DE01. Please check in table T001K.
This has to be done manually.
08-05-2014 12:33 PM
08-05-2014 3:27 PM
Faruq,
Answer (in your code) is a table, therefore, it is necessary LOOP command in Answer table for print the values below correctly.
LOOP answer.
WRITE : / answer-message.
ENDLOOP.
Best Regards,
Rafael Sá
08-05-2014 9:03 AM
Once your code will be execute then check SY-SUBRC Value or Return Value...Return value will show exactly where is the problem..
Regards,
Nadim
08-05-2014 12:16 PM
Hi Faruq ,
I think here answer table is with header line and you re trying to write header line and its empty
read table answer into ls_answer with key type = 'S'.
if sy-subrc eq 0.
write ls_answer-message.
endif.
08-05-2014 12:38 PM
08-05-2014 12:42 PM
So return table is not actually empty it has some error lines and its writing there you missed to fill some parameters for bapi.
08-05-2014 12:47 PM
Faruq,
Again, the Valuation area should belong to a Valuation class. What I understand is that the issue is due to incomplete data. Try providing a valid data set with all relevant parameters assigned. This should help.
08-05-2014 1:00 PM
Hi Faruq,
please change the following lines
mmarket-start_term = '04082014'.
mmarket-end_term = '04082014'.
to
mmarket-start_term = '20140805'.
mmarket-end_term = '20140805'.
and check the result.
Regards,
Klaus
08-05-2014 3:48 PM
08-05-2014 4:16 PM
Hi Sharmila,
the valuation class is not specified.
I also tried your suggestion
Same error
08-06-2014 8:07 AM
Hello everyone,
yesterday I found the solution .
Sharmila was right, a parameter was missing. Now I assigned the gen. valuation class to a producttype/companycode via spro SAPL0GH2 and it works like a charm .
Thank you all so much!
Faruq