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

ABAP: VBAP table data modify

aneel_munawar
Participant
0 Likes
10,442

Dea All,

Can I modify data of VBAP table .?  I  want to change the FKREL  field from A to C.

Regards,

Aneel

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,315

The question you should be asking, is "should you modify data of table VBAP"...  The answers you have received so far make me cry.

There is a massive gap between what you can technically do on a system, and what you should actually do.  There are all sorts of reasons why direct updates of standard SAP tables are bad.  If you search, you will find lots of discussions about them.

Cheers,

G.

32 REPLIES 32
Read only

Former Member
0 Likes
7,315

Moderator message: updating standard SAP table directly is a silly thing to do, and it is equally silly to advise others to do it.

Hello

go to se38-> type UPDATE-> hit F1.

*------------------------

TABLES VBAP.

UPDATE VBAP SET   FKREL = 'C'

               WHERE FKREL   = 'A' .

*------------------------

regrads

faiz rahman

Moderator message: updating standard SAP table directly is a silly thing to do, and it is equally silly to advise others to do it.

Message was edited by: Matthew Billingham

Read only

Former Member
0 Likes
7,315

Moderator message: updating standard SAP table directly is a silly thing to do, and it is equally silly to advise others to do it.

Hi,

If you are trying to multiple records then you can use the above logic which has suggested by Anish otherwise if you are trying to modify few records then please follow this process. its very simple.

in se11-> display the records whatever data you want to modify->enter /h in command box and select enter->then it will get the debugging mode->there change the value of Code(initally the value will be 'SHOW').

code = EDIT then you will get change mode there you can change the data.

Thanks & Regards,

Polu

Moderator message: updating standard SAP table directly is a silly thing to do, and it is equally silly to advise others to do it.

Message was edited by: Matthew Billingham

Read only

0 Likes
7,315

Hi Polu,

Are you suggesting that using debug to work around authorisation checks and directly update a standard SAP table is something you would actually consider doing on your's/your customer's systems?

Cheers,

G.

Read only

Former Member
0 Likes
7,316

The question you should be asking, is "should you modify data of table VBAP"...  The answers you have received so far make me cry.

There is a massive gap between what you can technically do on a system, and what you should actually do.  There are all sorts of reasons why direct updates of standard SAP tables are bad.  If you search, you will find lots of discussions about them.

Cheers,

G.

Read only

Colleen
Product and Topic Expert
Product and Topic Expert
0 Likes
7,315

I'm not a developer and I can see why some client sites have the developers sit a test before they are provided with a developer key and S_DEVELOP access.

Read only

0 Likes
7,315

You know, it's a place for developper here, only developper

sorry, hard day today

Fred

Read only

matt
Active Contributor
0 Likes
7,315

Hopefully my editing of those responses will allow you to dry your eyes. I was going to reject them, but I think I'll leave them with my comment, pour encourager les autres.

Read only

0 Likes
7,315

Agreed ,

Rather than rejecting these threads should be highlighted like this only.

This will make people stop themselves and think twice before posting any REALLY SILLY answers like this.

And this will even make them smile when after having  a long experience with SAP they turn back their earlier pages in SCN.

Read only

Former Member
0 Likes
7,315

Can I modify data of VBAP table .?

Yes.

Should I modify data of VBAP table .?

NO


Can you explain your requirement? what do you want to achieve?

Read only

Lakshmipathi
SAP Champion
SAP Champion
0 Likes
7,315

If you can explain the business process as to why you want to change in table instead of achieving via standard configuration, suitable suggestion can be given.  Also, you have not indicated at which stage you want to change.  After saving the sale order or creation of subsequent document ?  Need more detailed explanation

G. Lakshmipathi

Read only

Former Member
0 Likes
7,315

You should not change the transactional data of client directly from the table as all these changes are get stored and at the time of audit can cause issues. Ask your functional consultant to do it through front end.

Thanks

Read only

RaymondGiuseppi
Active Contributor
0 Likes
7,315

Did you try BAPI_SALESORDER_CHANGE.

NB: Don't update standard tables with OPEN-SQL statement, for database sake (or just database consistency)

But why do you want to change this field, is its valued determined thru Customizing (VOV7 ?) as well as history/flow of documents, so you should change other fields (e.g. ) to get this result. Ask functional to perform this requirement thru VA02, if they cannot, close.

Regards,

Raymond

Read only

aneel_munawar
Participant
0 Likes
7,315

Dear All,

Thanks for your reply and help. I  dont want to update the table by using direct sql. I want to use BAPI. I have used the fillowing code .  The system gives message that order has been updated but when I open the table, the data is not updated. The code is given below. Remember that I want to change the field 'FKREL'  of VBAP table from 'A' to 'C'. 

Regards,

Aneel


report zaneel.

  data: t_item like bapisditm occurs 0 with header line.

  data: t_itemx like bapisditmx occurs 0 with header line.

  data: t_return like bapiret2 occurs 0 with header line.

  data: bapisdh1x like bapisdh1x.

  data: t_vbap like vbap occurs 0 with header line.

  bapisdh1x-updateflag = 'u'.

  t_item-itm_number = '10'.

   t_item-bill_rel = 'A'.

  append t_item. t_itemx-itm_number = '10'.

   t_itemx-updateflag = 'u'.

   t_itemx-bill_rel = 'C'.

    append t_itemx.

    call function 'bapi_salesorder_change'

    exporting

       salesdocument = '0020000085'

       order_header_inx = bapisdh1x

        tables return = t_return

          order_item_in = t_item

          order_item_inx = t_itemx .

     loop at t_return where type = 'e'

        or type = 'a'.

        exit.

        endloop.

        if sy-subrc = 0.

           write: / 'sales order not updated',

            t_return-message.

            else.

               write: / 'sales order updated'. endif.

               commit work.

Read only

0 Likes
7,315

t_item-bill_rel = 'A'. < ---  this should be 'C'

t_itemx-bill_rel = 'C'. <-- this you try 'U" and 'X', one of them should affect.

Read only

0 Likes
7,315

I used this code then even data not changed.

REPORT zaneel.

DATA: t_item LIKE bapisditm OCCURS 0 WITH HEADER LINE.

DATA: t_itemx LIKE bapisditmx OCCURS 0 WITH HEADER LINE.

DATA: t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: bapisdh1x LIKE bapisdh1x.

DATA: t_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.

bapisdh1x-updateflag = 'U'.

t_item-itm_number = '000010'.

t_item-bill_rel = 'A'.

APPEND t_item.

t_itemx-itm_number = '000010'.

t_itemx-updateflag = 'U'.

t_itemx-bill_rel = 'X'.

APPEND t_itemx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

   EXPORTING

   salesdocument    = '0020000085'

   order_header_inx = bapisdh1x

   TABLES

   return           = t_return

   order_item_in    = t_item

   order_item_inx   = t_itemx.

COMMIT WORK.

LOOP AT t_return WHERE type = 'e'

    OR type = 'a'.

   EXIT.

ENDLOOP.

IF sy-subrc = 0.

   WRITE: / 'sales order not updated',

    t_return-message.

ELSE.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = 'X'.

   WRITE: / 'sales order updated'.

ENDIF.

COMMIT WORK.

Read only

0 Likes
7,315

t_item-bill_rel = 'A'.

Shouldnt this be 'C'?


Also try to debug to see if this value is passed onto vbap-fkrel or else you'll have to use some exit or badi for the same

Read only

0 Likes
7,315

It should become 'A'.  but it is not working.

Regards

Aneel

Read only

0 Likes
7,315

As I said already, with the functional configuration itself, this is possible but you need to answer to my queries already raised.  When some requirement can be achieved via functional configuration, why you are going for customized one?

G. Lakshmipathi

Read only

0 Likes
7,315

I want to change by using BAPI.  Why above code is not working.?

Regards,

Aneel

Read only

0 Likes
7,315

Did you have check the RETURN table of the BAPI function ?

Fred

Read only

0 Likes
7,315

Debug and check how the values are passed on, if you check the code in bapi, another FM SD_SALESDOCUMENT_CHANGE is called, now within this check -

perform ms_move_item_in  tables return
                                   item_in.

In this perform I dont see FKREL or BILL_REL being used so I think this field may not be used by the bapi to update FKREL.


I see a BTE in this ms_move_item_in_bte_00501020 you can use this to read itemin and populate vbapkom-fkrel

Read only

0 Likes
7,315

Yes , I have checked. It gives following message.

Regards,

Read only

0 Likes
7,315

Kartik,

When you search 'FKREL'  in table 'BAPISDITM' then it will take you to the field 'BILL_REL'.

Thats why I used this field.

Regards,

Read only

0 Likes
7,315

Aneel,

Sharing Lakshmipathi G's the point of view this change does not make much sense functionally!

The sales orders have to billed based on the quantity delivered.

You want to "forcefully" change it to quantity in order (more specifically target quantity) which is applicable in credit process etc.

Assuming that you can do this change in VBAP, after that business might encounter issues...to create subsequent documents, e.g. bill, quantity in bill etc. etc. (I don't really know what all problems can be faced)

I share the same thoughts as Raymond too

As your functional analyst for the reasons.

Typewriter

Read only

0 Likes
7,315

BILL_REL is indeed FKREL, but doesnt mean BAPI will update that automatically, as I mentioned ITEMIN-BILL_REL doesnt have any mapping to VBAPKOM-FKREL, so you need to use the BTE I mentioned above and move the values

Read only

0 Likes
7,315

First ask functional analyst to perform a demo with VA02, if he is not able to change the value, not much hope with the BAPI. (I'm nearly convinced this field is actually calculated from Customizing and changed during life of SO, e.g. already invoicde, material shipped, etc.) -> so note the data changed by functional and try to replicate in BAPI call, of course if requester is unable to change the value...

NB: I'm not sure (not SD/CRM specialist) but the flag you try to change in the BAPI call is CRM related ?

Regards,

Raymond

Read only

0 Likes
7,315

Btw do check with your functional consultant on why they dont want this to be done via config, config should be first priority, development should be take up only if there are limitation in doing this via config

Read only

0 Likes
7,315

Raymond,

As you said, FKREL (billing relevance) in VBAP comes from the item category used in the sales order, at line item.

In item category configuration VOV7, we set billing relevance.

So if we want to change VBAP-FKREL, the user changes the item category in the sales order. Only permitted to a certain stage in the sales process (logically so)

Directly changing FKREL without changing the item category might lead to many issues, if there is no copy control then billing quantity will be an issue etc.

Aneel,

So better don't do this change at table level

Or else...we don't know what other things might not work or work incorrectly.

Typewriter

Read only

0 Likes
7,315

So if his functional analyst is able to change item category, just code the same in BAPI, else not possible so try to refuse...  else -> Note 7 - Error caused by customer modification/development

Else if the actual requirement is correction of currently wrong values in database, look at good old correction reports like SDVBUK00 (Such reports can be found in some OSS notes)

Regards,

Raymond

Read only

0 Likes
7,315

added: aneel, as you want to change A to C, even by changing item category; I suggest do not do it

C is for completely different process, in comparison to A


Let business or functional handle this. (with VA02)

Aneel,

As suggested by Raymond,

Discuss this with your functional analyst -

- Why change to C?

as commented earlier, this is used for target qty e.g. credit process etc.

- try to change VBAP-PSTYV (item category)

(and not FKREL)

Typewriter

Message was edited by: TW Typewriter

Read only

JL23
Active Contributor
0 Likes
7,315

the usage of billing relevance in this BAPI is restricted to new dimension products like CRM, you can read this in 429160 - Billing-relevance indicator CRM: BTE interface

Read only

aneel_munawar
Participant
0 Likes
7,315

Thank you to all for helpful suggestions .

We will try to resolve it through SAP front end.

Regards,

Aneel