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: 

Problem to update VBAP-ERLRE field in a standard table----Its urgent

Former Member
0 Kudos
975

Hi friends,

ERLRE: Completion Rule

I need to create custom utility program to update ERLRE field(already it was set with B for thos specific orders,i need to upadte with null value for those) in production for specific orders.I checked FM: sd_salesdocument_change, but ITEM_IN STRUCTURE BAPISDITM ,ITEM_INX STRUCTURE BAPISDITMX OPTIONAL

those two structures not contain ERLRE field. Only ITEMS_EX STRUCTURE BAPISDIT OPTIONAL contain ERLRE field.

It does not have any x structure corresponding it.

Please help me how to update that field? Is there any other solution for that?

Thanks,

Monica

18 REPLIES 18

Former Member
0 Kudos
356

You would want to create a BDC session in this case. The BDC will "mimic" the end-user making the change manually. AND it will guarantee that your updates are done "correctly" from an SAP perspective.

Former Member
0 Kudos
356

Hi,

Thanks for your response.Its not changed by enduser, its incompletion log. When the order created or changed the incompletion log generated according to the input data. Can you plaese help me how to write BDC for va01 or va02.

Rather than BDC is there any FM or BAPI to update that field.

Thanks,

Monica

0 Kudos
356

Monica - have a look at FMs SD_SALESDOCUMENT_CHANGE and SD_SALESDOCUMENT_CREATE. They aren't released, but they do have documentation indicating that they are BAPIS.

Rob

0 Kudos
356

According to OSS note 93091:

For other business 
objects in purchasing, there are no separate BAPIs. For 
them, the rfc-capable function modules 
SD_SALESDOCUMENT_CREATE and SD_SALESDOCUMENT_CHANGE can 
be used. Those function modules can also be used in 
production by the customers. Since they have not been 
released, they may not be fully supported by SAP under 
certain circumstances. This would have to be checked in 
the individual cases.

Rob

0 Kudos
356

Sorry - I missed, that this was what you were looking at. Can't you use table ITEMS_EX?

Rob

Former Member
0 Kudos
356

Hi Rob,

This is the code i tried with items_ex struature,but its not updating vbap-erlre.

DATA: header_in LIKE bapisdhd1,

header_in_x LIKE bapisdhd1x,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

ITEMS_EX LIKE BAPISDIT OCCURS 0 with header line.

DATA: rec_ok TYPE char1.

DATA: t_vbak LIKE vbak OCCURS 0 WITH HEADER LINE.

DATA: t_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.

DATA: icnt TYPE i,

gcnt(1) TYPE c,

g_ordertype LIKE vbak-auart,

c_zso(3) TYPE c VALUE 'ZSO'. " sales order type

SELECT vbeln FROM vbak INTO corresponding fields of TABLE t_vbak

WHERE vbeln = '0070000007'.

CHECK sy-subrc = 0.

LOOP AT t_vbak.

  • Ini structures

CLEAR header_in.

CLEAR header_in_x.

  • Ini tables

CLEAR item_in.

REFRESH item_in.

CLEAR item_in_x.

REFRESH item_in_x.

CLEAR items_ex.

REFRESH items_ex.

CLEAR return.

REFRESH return.

SELECT vbeln posnr INTO CORRESPONDING FIELDS OF TABLE t_vbap

FROM vbap

WHERE vbeln = t_vbak-vbeln AND posnr = '000100'.

CHECK sy-subrc = 0.

  • Set header data

header_in_x-updateflag = 'U'.

  • Set line item data

LOOP AT t_vbap WHERE vbeln = t_vbak-vbeln.

  • items_ex-operation = 'UPD'.

items_ex-doc_number = t_vbap-vbeln.

items_ex-itm_number = t_vbap-posnr.

items_ex-updat_flag = 'U'.

items_ex-end_rule = ' '. "update end_rule(erlre)value B with null

APPEND items_ex.

CLEAR items_ex.

*

ENDLOOP.

  • Disable dialog

CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.

  • Run BAPI

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

EXPORTING

salesdocument = t_vbak-vbeln

order_header_in = header_in

order_header_inx = header_in_x

behave_when_error = 'P'

call_from_bapi = 'X'

TABLES

return = return

items_ex = items_ex.

  • Check for errors

IF sy-subrc = 0.

LOOP AT return.

IF return-type = 'E'.

rec_ok = 'N'.

EXIT.

ENDIF.

IF return-type = 'S'.

write:/ 'success'.

ENDIF.

ENDLOOP.

IF rec_ok = 'N'.

ROLLBACK WORK.

ELSE.

COMMIT WORK AND WAIT.

WRITE:/ 'Success_flag?'.

ENDIF.

ENDIF.

ENDLOOP.

0 Kudos
356

Have a look at the domain values for:


items_ex-operation and items_ex-updat_flag.

They are:


Operation:
003	Delete: Message contains objects to be deleted
004	Change: Message contains changes
005	Replace: This message replaces previous messages
009	Original: First message for process
023	Wait/Adjust: Data should not be imported
018	Resend

UPDAT_FLAG:
(blank) Do not create document flow records
X	Create document flow records
2	Create doc. flow records except for dely/goods issue/billdoc

Rob

Former Member
0 Kudos
356

Hi Rob,

Thanks for helping me.I tried with this. Its not updating table field. Am i doing anything wrong.Please help me how to update. I am trying to update vbeln 0090000137 erlre already 'B' is there, i am trying to update with 'c',but its not and even its not showing any error message.

DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

ITEMS_EX LIKE BAPISDIT OCCURS 0 with header line.

DATA: rec_ok TYPE char1.

DATA: t_vbak LIKE vbak OCCURS 0 WITH HEADER LINE.

DATA: t_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.

DATA: icnt TYPE i,

gcnt(1) TYPE c,

g_ordertype LIKE vbak-auart,

c_zso(3) TYPE c VALUE 'ZSO'. " sales order type

SELECT vbeln FROM vbak INTO corresponding fields of TABLE t_vbak

WHERE vbeln = '0090000137'.

CHECK sy-subrc = 0.

LOOP AT t_vbak.

  • Ini structures

CLEAR header_in.

CLEAR header_in_x.

  • Ini tables

CLEAR items_ex.

REFRESH items_ex.

CLEAR return.

REFRESH return.

SELECT vbeln posnr INTO CORRESPONDING FIELDS OF TABLE t_vbap

FROM vbap

WHERE vbeln = t_vbak-vbeln AND posnr = '000100'.

CHECK sy-subrc = 0.

  • Set header data

header_in_x-updateflag = 'U'.

  • Set line item data

LOOP AT t_vbap WHERE vbeln = t_vbak-vbeln.

items_ex-operation = '005'.

items_ex-doc_number = t_vbap-vbeln.

items_ex-itm_number = t_vbap-posnr.

items_ex-updat_flag = ' '.

items_ex-end_rule = 'C'. "already erlre in vbap is 'B' try to replace w

APPEND items_ex.

CLEAR items_ex.

*

ENDLOOP.

  • Disable dialog

CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.

  • Run BAPI

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

EXPORTING

salesdocument = t_vbak-vbeln

order_header_in = header_in

order_header_inx = header_in_x

behave_when_error = 'P'

call_from_bapi = 'X'

TABLES

return = return

  • item_in = item_in

  • item_inx = item_in_x

items_ex = items_ex.

  • Check for errors

IF sy-subrc = 0.

LOOP AT return.

IF return-type = 'E'.

rec_ok = 'N'.

EXIT.

ENDIF.

IF return-type = 'S'.

write:/ 'success'.

ENDIF.

ENDLOOP.

IF rec_ok = 'N'.

ROLLBACK WORK.

ELSE.

COMMIT WORK AND WAIT.

WRITE:/ 'Success_flag?'.

ENDIF.

ENDIF.

ENDLOOP.

0 Kudos
356

A shot in the dark - try using UPDAT_FLAG:

* Set line item data
LOOP AT t_vbap WHERE vbeln = t_vbak-vbeln.

  items_ex-operation = '005'.
  items_ex-doc_number = t_vbap-vbeln.
  items_ex-itm_number = t_vbap-posnr.
  items_ex-updat_flag = 'X'.
  items_ex-end_rule = 'C'. 
  APPEND items_ex.
  CLEAR items_ex.
*
ENDLOOP.

Former Member
0 Kudos
356

Hi Rob,

I am doing the same way what you told, but its not updation data in table. Can you please check my code what i had done.

DATA: header_in LIKE bapisdhd1,

header_in_x LIKE bapisdhd1x,

item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,

item_in_x LIKE bapisditmx OCCURS 0 WITH HEADER LINE,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

ITEMS_EX LIKE BAPISDIT OCCURS 0 with header line.

DATA: rec_ok TYPE char1.

DATA: t_vbak LIKE vbak OCCURS 0 WITH HEADER LINE.

DATA: t_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.

DATA: icnt TYPE i,

gcnt(1) TYPE c,

g_ordertype LIKE vbak-auart,

c_zso(3) TYPE c VALUE 'ZSO'. " sales order type

SELECT vbeln FROM vbak INTO corresponding fields of TABLE t_vbak

WHERE vbeln = '0090000141'.

CHECK sy-subrc = 0.

LOOP AT t_vbak.

  • Ini structures

CLEAR header_in.

CLEAR header_in_x.

  • Ini tables

CLEAR item_in.

REFRESH item_in.

CLEAR item_in_x.

REFRESH item_in_x.

CLEAR items_ex.

REFRESH items_ex.

CLEAR return.

REFRESH return.

SELECT vbeln posnr INTO CORRESPONDING FIELDS OF TABLE t_vbap

FROM vbap

WHERE vbeln = t_vbak-vbeln AND posnr = '000100'.

CHECK sy-subrc = 0.

  • Set header data

header_in_x-updateflag = 'U'.

  • Set line item data

LOOP AT t_vbap WHERE vbeln = t_vbak-vbeln.

items_ex-operation = '005'.

items_ex-doc_number = t_vbap-vbeln.

items_ex-itm_number = t_vbap-posnr.

items_ex-updat_flag = 'X'.

items_ex-end_rule = 'C'.

APPEND items_ex.

CLEAR items_ex.

ENDLOOP.

  • Disable dialog

CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.

  • Run BAPI

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

EXPORTING

salesdocument = t_vbak-vbeln

order_header_in = header_in

order_header_inx = header_in_x

behave_when_error = 'P'

call_from_bapi = 'X'

TABLES

return = return

  • item_in = item_in

  • item_inx = item_in_x

items_ex = items_ex.

  • Check for errors

IF sy-subrc = 0.

LOOP AT return.

IF return-type = 'E'.

rec_ok = 'N'.

EXIT.

ENDIF.

IF return-type = 'S'.

write:/ 'success'.

ENDIF.

ENDLOOP.

IF rec_ok = 'N'.

ROLLBACK WORK.

ELSE.

COMMIT WORK AND WAIT.

WRITE:/ 'Success_flag?'.

ENDIF.

ENDIF.

ENDLOOP.

0 Kudos
356

Some things you can try:

What messages are in return?

Is the commit being performed? Try it without waiting.

Is the other data being updated.

Rob

Former Member
0 Kudos
356

Hi Rob,

In return i am getting two records:

1.

Type: S

ID :V4

Number: 233

Message: ORDER_HEADER_IN has been processed successfully

Message-v1:VBAKKOM

parameter:ORDER_HEADER_IN

system :dv1030

2.

Type: S

ID :V1

Number: 041

Message: No data was changed

parameter:ORDER_HEADER_IN

system :dv1030

I tried commit without wait, but its not updating.

0 Kudos
356

Have you tried updating other fields in this segment? Does it work?

Rob

Former Member
0 Kudos
356

Hi Rob,

I tried with same program with item_in,item_in_x for abgru field,its updating in vbap. This is the first time i am using this items_ex structure. Have you ever used this structure to update any field . If you have anything,Can you please send me the tset code?

Thanks for your help.

0 Kudos
356

I meant - is anything else in items_ex getting updated?

Rob

0 Kudos
356

No. Only i am trying to update erlre field.

Thanks,

monica

0 Kudos
356

I'm suggesting that you try updating other fields in items_ex.

Rob

0 Kudos
356

Hi Rob,

I tried for this field.

LOOP AT t_vbap WHERE vbeln = t_vbak-vbeln.

items_ex-operation = '005'.

items_ex-doc_number = t_vbap-vbeln.

items_ex-itm_number = t_vbap-posnr.

items_ex-updat_flag = 'X'.

items_ex-item_categ = 'ZSO2'. "already set with zs01.

APPEND items_ex.

CLEAR items_ex.

ENDLOOP.

Its not updated. I was thinking that the way to use items_ex may be wrong to update field. I dont know exacatly how to use this structure to update field.

This is the first time i am using.

I appreciated your help.