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

Update BSID table

Former Member
0 Likes
4,158

Hi All,

Is there a standard function module to update BSID table. Thanks

regards

Siby

18 REPLIES 18
Read only

former_member386202
Active Contributor
0 Likes
3,255

Hi,

I don't think so but u can do like this.

&----


*& Form SUB_READ_UPDATE_BSEG

&----


  • text

----


FORM sub_read_update_bseg.

IF NOT it_final[] IS INITIAL.

LOOP AT it_final INTO wa_final.

UPDATE bseg SET zuonr = wa_final-ccnum

WHERE bukrs EQ wa_final-bukrs

AND belnr EQ wa_final-vbeln

AND rfzei EQ wa_final-rfzei

AND saknr NE ' '.

ENDLOOP.

*--Message data updated successfully

MESSAGE i888 WITH text-002.

LEAVE LIST-PROCESSING.

ELSE.

*--Message No data found

MESSAGE i888 WITH text-003.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " SUB_READ_UPDATE_BSEG

Regards,

Prashant

Read only

JozsefSzikszai
Active Contributor
0 Likes
3,255

hi Sibi,

tables like BSID are updated by transactions (or complex FMs), because of the integrity of the system. Which field do you want to update at all?.

ec

Read only

0 Likes
3,255

Hi,

I want to update ZLSCH (Payment Method) field for a customer credit note.

Read only

0 Likes
3,255

you can use tranaction FB09 for modifiing line items in FI. You can easily develop a program which uses BDC or call transaction to do this. If you need more help, just let me know.

Read only

0 Likes
3,255

FB09 is not an executable program and in do not see BSID anywhere here.

Can anyone answer this question with a code sample?

It has been asked multiple times but there is not a single answer fitting the job here.

Me I want to update BSID-ZLSCH among others.

Read only

0 Likes
3,255

Read more carefully, FB09 is a transaction not a program (update line item, where FB02 is update document), use SHDB to build a small BDC wrapper report (very easy, try it) or use a FM like FI_ITEMS_MASS_CHANGE (which will build a BDC for FB02)

BSID in only a copy (secondary index) of some BSEG items for performance (not cleared, debitor) so update MUST come from BSEG standard updates.

Regards,

Raymond

Read only

0 Likes
3,255

Hi Raymond

There are several things that I do not understand and/or are wrong in your answer:

- SHDB is for recording purposes, not for updating let alone that it is a code generator;

- I have yet to see a usable, reliable and understandable BDC report. Wrapper is a Java term meaning something totally not bound to this subject;

- I saw FI_ITEMS_MASS_CHANGE and it does not seem to do anything with BSID or BSEG;

- I have used BSID as a real table and never BSEG, and I do not understand what you mean here by copy. A secondary index is totally not related, that is something you use to look up database records if you can not select on primary key.

Can you (or anyone else) tell me how to update standard SAP tables with BDC or how to update BSID (through BSEG?) (preferably by coding sample)?

BR Dennis

Read only

0 Likes
3,255
  • When I wrote "use SHDB to build a small BDC wrapper report", How did you understand that SHDB will update your data ?
  • Wrapper is a common english word, not only a java concept, look at wikipedia for "wrapper function" in Computing.
  • Look much more carefully to  FI_ITEMS_MASS_CHANGE documentation, and at the first parameter structure
  • Look at help.sap.com and OSS notes to find the definition of financial secondary indexes which were created cause BSEG is a cluster/pool table to optimize database access. Those tables must NEVER been updated by user, they are updated by update FM to reflect BSEG update, and must be coherent with BSEG data (eg. when clearing record are copied from BSIx to BSAx and removed from first table) (Also description of BSID is "Accounting: Secondary Index for Customers")

Regards,

Raymond

Read only

0 Likes
3,255

I start to believe I might be able to use FI_ITEMS_MASS_CHANGE but still it is too vague..

I could understand it with just the importing and exporting parameter since I would then give in a BSEG record to update, nothing special about that.

It seems it_fldtab does nothing more than listing which fields are updated, I can do that.

But what to do with IT_BUZTAB? It seems to be a few key fields from BSEG, but I believe I already put those in S_BSEG.

Also I do not see how I could have more than one table line.

If I would have to put all my records in it to update I would understand that but then S_BSEG is not clear to me since I now have more than one BSEG record so what could be the logic of S_BSEG..

Maybe with the answer to this I can produce working code to update BSEG and implicit BSID, and put it here as an instructive example.

Read only

0 Likes
3,255

Fill the parameters so :

  • IT_FLDTAB -> Name of fields to update
  • IT_BUZTAB -> Current values in BSEG -> List of items to update (fill it with a SELECT INTO TABLE statement)
  • S_BSEG -> New values of field to update (only value of field of IT_FLDTAB will be used)

This FM allow to apply the same change to multiple items.

Else, record transaction FB09 with SHDB and generate a program with this transaction (don't call it a wrapper if it cause trouble)

Regards,

Raymond

Read only

0 Likes
3,255

though this seems to be ok, I see that BSID and BSEG are not identical in all columns.

How should I copy with that since I have to update the BSEG record to get to the BSID record?

Read only

0 Likes
3,255

Read current values from BSEG, as

though this seems to be ok, I see that BSID and BSEG are not identical in all columns.

can be a serious problem of database consistency, try to diagnose this with report RFINDEX (read its documentation) and  raise an OSS message (component FI-GL-GL-X) if it returns inconsistencies joint the report results to the message. (theorically, only SAP can use the correction report)

Regards,

Raymond

Read only

0 Likes
3,255

I meant column names differed between BSID and BSEG, not the content..

Anyway it seems not to work.. I get the non-informative message 'No changes were made'.

My code is this:

TYPE-POOLS : tpit.



DATA:

      lw_bseg_new_values      TYPE bseg,

      it_errtab TYPE tpit_t_errdoc WITH HEADER LINE,

       it_fldtab TYPE tpit_t_fname WITH HEADER LINE,

       it_buztab TYPE tpit_t_buztab WITH HEADER LINE.



" Retrieve BSEG records.

SELECT * FROM bseg

  INTO CORRESPONDING FIELDS OF TABLE it_buztab UP TO 2 ROWS.



" Set the new field value for the BSEG.

lw_bseg_new_values-bschl = 'TE'.



" Mention the fields to change.

it_fldtab-fname = 'BSCHL'.

APPEND it_fldtab.



" Perform the update.

CALL FUNCTION 'FI_ITEMS_MASS_CHANGE'

  EXPORTING

    s_bseg     = lw_bseg_new_values

  IMPORTING

    errtab     = it_errtab[]

  TABLES

    it_buztab  = it_buztab

    it_fldtab  = it_fldtab

  EXCEPTIONS

    bdc_errors = 1

    OTHERS     = 2.

IF sy-subrc <> 0.

  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Do you see an error here?

If this is correct it does not seem to work and it would be undoable to debug the whole FB02 which is called inside the function module.

Let me know if you need any debug shot to answer this and on what moment.

BR Dennis

Read only

0 Likes
3,255

BSCHL cannot be modified. Look via Customizing on available fields list : Financial Accounting, Financial Accounting Global Settings, Document, Line Item, Document Change Rules, Line Item.

Regards,

Raymond

PS: The FM seems to be more restrictive than transactions FB02/FB09, look at form SCREEN_DETAIL in include LFI_ITEMSF03.

Read only

0 Likes
3,255

Now I try to do it with KIDNO which should be okay according to this list:

" Set the new field value for the BSEG.
lw_bseg_new_values-KIDNO = 'TESTTESTTESTTESTTESTTESTTEST'.
" Mention the fields to change.
it_fldtab-fname = 'KIDNO'.
APPEND it_fldtab.

Instead of the BSCHL lines above.

But I still get the same error, also when I put X in AENKZ in IT_FLDTAB it does not make a difference..

Read only

0 Likes
3,255

What is your version, on my ECC6 Ehp4, KIDNO not allowed in Customizing. As it is not managed by the FM, you must create the BDC yourself.

So try to change this field via transaction FB02 or FB09, read the source of the form, look for the Customizing.

For old version, look for OSS notes to implement.

Regards;

Raymond

Read only

0 Likes
3,255

Would you know which BSEG field I can update for this function module? Then I will try it with this one.. I really hope to get it working at least for one field it would be helpful for us to get this working even if just for futural versions. I have no idea about my version..

Read only

Former Member
0 Likes
3,255

I got a program here that works.

Be sure to edit the belnr and bukrs to an existing record in your own database.

Do not only use belnr since this use s less of the full primary index and can cause performance issues..

*&---------------------------------------------------------------------*

*& Report  ZTEST_FB02

*&

*&---------------------------------------------------------------------*

*& Demo program for FI_ITEMS_MASS_CHANGE, a module to update BSEG.

*&

*&---------------------------------------------------------------------*



REPORT  ztest_fb02.

TYPE-POOLS : tpit.



DATA : w_bseg TYPE bseg,

w_message TYPE t100-text.



DATA : it_errtab TYPE tpit_t_errdoc WITH HEADER LINE,

       it_fldtab TYPE tpit_t_fname WITH HEADER LINE,

       it_buztab TYPE tpit_t_buztab WITH HEADER LINE.



* Field name to be changed

it_fldtab-fname = 'ZUONR'.

APPEND it_fldtab.

CLEAR it_fldtab.



* Field value

w_bseg-zuonr = 'TESTtest'.



* ITEM 7

SELECT bukrs belnr gjahr buzei koart umskz bschl mwart mwskz

  FROM bseg INTO CORRESPONDING FIELDS OF TABLE it_buztab

  WHERE belnr = '0411219696' AND bukrs = '0010'.



CALL FUNCTION 'FI_ITEMS_MASS_CHANGE'

  EXPORTING

    s_bseg     = w_bseg

  IMPORTING

    errtab     = it_errtab[]

  TABLES

    it_buztab  = it_buztab

    it_fldtab  = it_fldtab

  EXCEPTIONS

    bdc_errors = 1

    OTHERS     = 2.

IF sy-subrc <> 0.

  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Raymond thanks for your input:)