Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPIRET2 empty message and type

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

29 REPLIES 29

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Hello Faruq,

  1. The filed 'RETURN' is a structure in FM BAPI_FTR_CREATEFROMDATA
  2. 'RETURN' is nowhere filled in FM BAPI_FTR_CREATEFROMDATA
  3. I suggest debug FM BAPI_FTR_CREATEFROMDATA and check the contents in internal table 'l_tab_return'.
  4. You may need to implement implicit enhancement to export the values of 'l_tab_return' to memory in FM BAPI_FTR_CREATEFROMDATA and the same can be imported in your program.


Thanks

0 Kudos

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

0 Kudos

Hello Faruq,

Please share the message number and message class.

Thanks

0 Kudos

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

0 Kudos

Hello faruq,

Share the contents of answer structure.

0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos


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.

0 Kudos

Thanks Sharmila,

changed without effect.

0 Kudos

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.



  1. CALL FUNCTION 'BAPI_FTR_CREATEFROMDATA' 
  2.    EXPORTING 
  3.      MONEYMARKET     = mmarket 
  4. *   FOREIGNEXCHANGE = 
  5.      COMPANYCODE     = 'DE01' 
  6.      PRODUCTTYPE     = '510' 
  7.    IMPORTING 
  8.      RETURN          = answer 
  9.      TRANSACTION     = ls_transaction 
  10.      COMPANYCODE     = ls_companycode 
  11.    EXCEPTIONS 
  12.      ERROR           = 1 
  13.      OTHERS          = 2. 
  14.   
  15. IF SY-SUBRC <> 0. 
  16. *         Implement suitable error handling here 
  17.    WRITE : / 'Fehler im System'. 
  18. ENDIF. 


0 Kudos

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

0 Kudos


There is no valuation area assigned to the company code DE01. Please check in table T001K.

This has to be done manually.

0 Kudos

Hi Sharmila,

the valuation area is assigned.

RJSA
Active Participant
0 Kudos

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á

Former Member
0 Kudos

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

asim_isik
Active Participant
0 Kudos

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.

Former Member
0 Kudos

The messages from BAPI_FTR_FTD_CREATE L_TAB_RETURN


0 Kudos

So return table is not actually empty it has some error lines and its writing there you missed to fill some parameters for bapi.

0 Kudos

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.

0 Kudos

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

0 Kudos

Hi Klaus,

already done with the same result.

Thanks,

Faruq

0 Kudos

Hi Sharmila,

the valuation class is not specified.

I also tried your suggestion

Same error

Former Member
0 Kudos

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