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

problem with BAPI_PR_CHANGE

Former Member
0 Likes
1,506

Hi,

I've an interactive ALV that shows some info about orders request... In this ALV you can make changes in some fields like preis (price), menge (quantity), matnr and some others of an order request.

I'm using BAPI_PR_CHANGE to fix this changes in EBAN table, but unsuccessfully

I think i'm giving the correct values to the parameter of this BAPI, even in the returned table I_MESS (table returned by the BAPI) i can read messages like this: "Request order 10000520 has been modified" but the values of fileds i've changed using ALV are the same as before...

Someone could help me please? I'm becoming crazy with this, i don't know what to do...

THANKS!!!

This is the code of the FORM that must save changes made in ALV in EBAN table:

FORM grabar_modificaciones .

DATA: l_cadena(1000) TYPE c,

l_long TYPE i,

l_length TYPE i.

  • Tablas internas

TYPES: BEGIN OF t_requ_items.

INCLUDE STRUCTURE bapimereqitem.

TYPES: END OF t_requ_items.

DATA: i_requ_items TYPE TABLE OF t_requ_items.

DATA: wa_requ_items TYPE t_requ_items.

TYPES: BEGIN OF t_req_account_assignment.

INCLUDE STRUCTURE bapimereqaccount.

TYPES: END OF t_req_account_assignment.

DATA: i_req_account_assignment TYPE TABLE OF t_req_account_assignment.

DATA: wa_req_account_assignment TYPE t_req_account_assignment.

TYPES: BEGIN OF t_requisition_add .

INCLUDE STRUCTURE bapimerqaddrdelivery.

TYPES: END OF t_requisition_add .

DATA: i_requisition_add TYPE TABLE OF t_requisition_add .

DATA: wa_requisition_add TYPE t_requisition_add .

TYPES: BEGIN OF t_cabezera .

INCLUDE STRUCTURE bapimereqheader.

TYPES: END OF t_cabezera .

DATA: i_cabezera TYPE TABLE OF t_cabezera .

DATA: wa_cabezera TYPE t_cabezera .

DATA: i_chang_cabez LIKE bapimereqheaderx OCCURS 0 WITH HEADER LINE.

TYPES: BEGIN OF t_change_item .

INCLUDE STRUCTURE bapimereqitemimp .

TYPES: END OF t_change_item .

DATA: i_change_item TYPE TABLE OF t_change_item .

DATA: wa_change_item TYPE t_change_item.

DATA: i_change_itemx LIKE bapimereqitemx OCCURS 0 WITH HEADER LINE.

TYPES: BEGIN OF t_change_accu .

INCLUDE STRUCTURE bapimereqaccount.

TYPES: END OF t_change_accu.

DATA: i_change_accu TYPE TABLE OF t_change_accu.

DATA: wa_change_accu TYPE t_change_accu.

DATA: i_change_accux LIKE bapimereqaccountx OCCURS 0 WITH HEADER LINE.

TYPES: BEGIN OF t_change_addr.

INCLUDE STRUCTURE bapimerqaddrdelivery.

TYPES: END OF t_change_addr.

DATA: i_change_addr TYPE TABLE OF t_change_addr.

DATA: wa_change_addr TYPE t_change_addr.

TYPES: BEGIN OF t_change_text.

INCLUDE STRUCTURE bapimereqitemtext.

TYPES: END OF t_change_text.

DATA: i_change_text TYPE TABLE OF t_change_text.

DATA: wa_change_text TYPE t_change_text.

DATA: i_mess LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: i_xeban TYPE STANDARD TABLE OF ueban,

i_yeban TYPE STANDARD TABLE OF ueban,

w_xeban TYPE ueban,

w_yeban TYPE ueban.

DATA: l_flag_c(1) TYPE c,

l_preis TYPE bapicurext.

CLEAR l_flag_c.

LOOP AT i_alv_data INTO w_alv_data WHERE marca EQ 'X'.

l_flag_c = 'X'.

READ TABLE %g00 WITH KEY eban-banfn = w_alv_data-banfn

eban-bnfpo = w_alv_data-bnfpo.

  • Recuperar los datos de la solicitud de pedido

CALL FUNCTION 'BAPI_PR_GETDETAIL'

EXPORTING

number = w_alv_data-banfn

account_assignment = 'X'

item_text = 'X'

delivery_address = 'X'

TABLES

return = i_mess

pritem = i_requ_items

praccount = i_req_account_assignment

praddrdelivery = i_requisition_add.

  • pritemtext = i_requisition_text.

MOVE-CORRESPONDING w_alv_data TO w_xeban.

  • Verificar si se trata de: modificacion item o añadir item

READ TABLE i_requ_items INTO wa_requ_items WITH KEY preq_item = w_alv_data-bnfpo.

IF sy-subrc = 0. " Modificar el item.

wa_cabezera-preq_no = w_alv_data-banfn.

wa_cabezera-pr_type = %g00-eban-bsart.

wa_cabezera-item_intvl = w_alv_data-bnfpo.

wa_cabezera-last_item = w_alv_data-bnfpo.

APPEND wa_cabezera TO i_cabezera.

i_chang_cabez-preq_no = 'X'.

i_chang_cabez-pr_type = 'X'.

i_chang_cabez-item_intvl = 'X'.

i_chang_cabez-last_item = 'X'.

APPEND i_chang_cabez.

MOVE-CORRESPONDING wa_requ_items TO wa_change_item.

wa_change_item-short_text = w_alv_data-txz01.

wa_change_item-material = w_alv_data-matnr.

wa_change_item-matl_group = w_alv_data-matkl.

wa_change_item-quantity = w_alv_data-menge.

wa_change_item-unit = w_alv_data-meins.

IF wa_change_item-preq_price NE w_alv_data-preis.

l_preis = w_alv_data-preis.

wa_change_item-preq_price = l_preis.

w_xeban-frgkz = 'Z'.

w_xeban-frgzu = sy-datum.

ENDIF.

wa_change_item-fixed_vend = w_alv_data-flief.

APPEND wa_change_item TO i_change_item.

PERFORM modificar_itemx TABLES i_change_itemx

USING w_alv_data-banfn.

READ TABLE i_req_account_assignment INTO wa_req_account_assignment WITH KEY preq_item = w_alv_data-bnfpo.

IF sy-subrc = 0. " Grabar datos del cuenta.

MOVE-CORRESPONDING wa_req_account_assignment TO wa_change_accu.

APPEND wa_change_accu TO i_change_accu.

ENDIF.

READ TABLE i_requisition_add INTO wa_requisition_add WITH KEY preq_item = w_alv_data-bnfpo.

IF sy-subrc = 0. " Grabar datos del cuenta.

MOVE-CORRESPONDING wa_requisition_add TO wa_change_addr.

APPEND wa_change_addr TO i_change_addr.

ENDIF.

wa_change_text-preq_no = w_alv_data-banfn.

wa_change_text-preq_item = w_alv_data-bnfpo.

wa_change_text-text_id = 'B08'.

wa_change_text-text_form = ' '.

l_cadena = w_alv_data-mat_txt.

l_long = STRLEN( l_cadena ).

IF l_long > 132.

DO.

l_long = STRLEN( l_cadena ).

IF l_long > 132.

wa_change_text-text_line = l_cadena(132).

APPEND wa_change_text TO i_change_text.

l_length = l_length + 132.

l_cadena = w_alv_data-mat_txt+l_length(132).

ELSE.

wa_change_text-text_line = l_cadena.

wa_change_text-text_form = ' '.

APPEND wa_change_text TO i_change_text.

EXIT.

ENDIF.

ENDDO.

ELSE.

wa_change_text-text_line = l_cadena.

APPEND wa_change_text TO i_change_text.

ENDIF.

ENDIF.

  • Llamar a la bapi para grabar los cambios

CALL FUNCTION 'BAPI_PR_CHANGE'

EXPORTING

number = w_alv_data-banfn

prheader = wa_cabezera

prheaderx = i_chang_cabez

TABLES

return = i_mess

pritem = i_change_item

pritemx = i_change_itemx

praccount = i_change_accu

praccountx = i_change_accux

praddrdelivery = i_change_addr

pritemtext = i_change_text.

MOVE-CORRESPONDING w_alv_data TO w_xeban.

w_xeban-frgkz = 'Z'.

w_xeban-frgzu = sy-datum.

APPEND w_xeban TO i_xeban.

ENDLOOP.

IF NOT i_xeban[] IS INITIAL.

  • Función que realiza los cambios en la tabla EBAN

CALL FUNCTION 'Z004M_RPT_REQREL'

TABLES

xeban = i_xeban.

  • yeban = i_yeban.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

IF l_flag_c IS INITIAL.

MESSAGE i998(00).

EXIT.

ENDIF.

ENDFORM. " GRABAR_MODIFICACIONES

3 REPLIES 3
Read only

andrea_galluccio2
Contributor
0 Likes
976

Hi,

put the BAPI_TRANSACTION_COMMIT inside the loop.

I think that each BAPI call needs to be confirmed by a BAPI COMMIT.

I think you cannot use just ONE COMMIT for all records (one time did the same thing - one commit for all BAPI calls - and it wasn't works for me).

Hope it helps

Bye

Andrea

Read only

GuyF
Active Participant
0 Likes
976

Hi,

Are the values changed for your PR? That is, if you look at the tables themselves it's working?

If it's not, then you've got a problem with your BAPI and will need to check it more.

If it is updating the tables, but not your ALV, you need to refresh your ALV grid.

First change the values in the table the ALV grid is using.

Then, in the structure of the USER_COMMAND form you need to do the following:

FORM user_command USING iv_ucomm    TYPE sy-ucomm.
                        is_selfield TYPE slis_selfield

* ... your code here

  is_selfield-refresh = 'X'.
ENDFORM.

Hope this helps,

Guy.

Read only

Former Member
0 Likes
976

It was my fault, i was fixing bad one parameter. In "item" i was fixing field banfn instead of banfpo...

Anyway, thanks Andrea and Guy F. for your fast colaboration

Regards.