Application Development and Automation 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: 
Read only

Doubt about BAPI_CONTRACT_CHANGE

ronaldo_aparecido
Contributor
0 Likes
1,285

Good morning Gurus.

I want to know how to connect an error message that is in the 't_return' to the corresponding item number to generate the ALV for the user.

CALL FUNCTION 'BAPI_CONTRACT_CHANGE'

             EXPORTING

               purchasingdocument = v_purchasingdocument

             TABLES

               item               = t_item

               itemx              = t_itemx

               item_text          = t_item_text

               return             = t_return.



For example:T_item has 10 itens and t_return have 2 errors How do I know which of the 10 items are in error.


Please see attach.


Thanks Gurus.

1 ACCEPTED SOLUTION
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,237

Normally in case it is realted to any line then in variable MSG_V1/MSG_V2/MSG_V3/MSG_V4 in either one of these you will find the item number

4 REPLIES 4
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,238

Normally in case it is realted to any line then in variable MSG_V1/MSG_V2/MSG_V3/MSG_V4 in either one of these you will find the item number

Read only

0 Likes
1,237

Hi I used the fiel row and worked!!! thanks .

Read only

0 Likes
1,237

Yes use BAPIRET2-ROW, you may also use BAPIRET2-FIELD to give a better report to user in case the value of the field is not in one of the four MESSAGE_V* fields.


IF bapiret2-field IS NOT INITIAL.

     ASSIGN COMPONENT (bapiret2-field) OF STRUCTURE bapiitemstructure TO <FS>.

     IF sy-subrc EQ 0.

          MOVE bapiret2-field TO columnerrorfieldname.

          WRITE <fs> TO columnerrorfieldvalue.

     ENDIF.

ENDIF.

Eventually use a call of CL_ABAP_TYPEDESCR->DESCRIBE_BY_NAME or other tool to give the field name (e.g. "plant invalid", "PLT1)

LineFieldValueMessage
10 (BAPIRET2-ROW)Storage Location (from BAPIRET2-FIELD)XXXX (from ASSIGN)Error message (BAPIRET2-MESSAGE)

Regards,

Raymond

Read only

0 Likes
1,237

Hello,

I am currently maintaining a program using BAPI_CONTRACT_CHANGE, where the messages in the RETURN table are associated to the relevant contract item using the ROW column, and it seems that it does not work in case of deleted items.

The contract looks like this:

The messages for items 6800 and 6810 have return-row = 2,

the message for item 6830 has return-row = 5.

These row ids are the ids of the previous non-deleted row, but it results in an incorrect mapping.

I guess I have to switch to the other osolution, i.e. searching for the item id in MSG_V1/MSG_V2/MSG_V3/MSG_V4.

Any other idea?

Thanks in advance,

Magalie