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

FI_DOCUMENT_CHANGE

0 Likes
22,210

Hello Experts,

I have to update the text field SGTXT of BSEG with few texts by code. Am using the FM

FI_DOCUMENT_CHNAGE to do that. The sy-subrc returns 0. But the texts doesn't update on the

line item of the document. I have made use of 'COMMIT WORK'. Yet no go.

gs_accchg-fdname = 'SGTXT'.

gs_accchg-newval = itab-sgtxt.

APPEND gs_accchg TO gt_accchg.

CLEAR gs_accchg.

CALL FUNCTION 'FI_DOCUMENT_CHANGE'

EXPORTING

i_awtyp = gs_bkpftab-awtyp

i_awref = gs_bkpftab-awkey+00(10)

i_aworg = gs_bkpftab-awkey+10(10)

i_buzei = gs_bsegtab-buzei

TABLES

t_accchg = gt_accchg

EXCEPTIONS

no_reference = 1

no_document = 2

many_documents = 3

wrong_input = 4

overwrite_creditcard = 5

OTHERS = 6.

COMMIT WORK.

Request to suggest if am missing something here.

Thanks and Regards in advance

Kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
10,893

Hi,

Better try to pass the old value also..


gs_accchg-fdname = 'SGTXT'.
gs_accchg-oldval = "pass the old value.
gs_accchg-newval = itab-sgtxt.
APPEND gs_accchg TO gt_accchg.
CLEAR gs_accchg.

Regards,

Dhina..

17 REPLIES 17
Read only

former_member191735
Active Contributor
0 Likes
10,893

Pass old value too.

Also try passing value to: i_awsys

Read only

0 Likes
10,893

Hello Sampath,

Thank you for the answer, but it didnt help much. The sy-subrc stays still zero, but the records are not updated.

Thanks and Regards

Kumar

Read only

0 Likes
10,893

Hi,

Did you try using 'BAPI_TRANSACTION_COMMIT'?

Thanks,

Archana

Read only

0 Likes
10,893

Yes Archana, I did even that..But no luck, i think am missing something here. Since the sy-subrc is 0, The document is good. But the BSEG doesnt get updated. Debugging the Standard FM shows me that *bseg is being compared, i assume that some other FM is to be called before this one to fill the *BSEG buffer.

Thanks and Regards

Kumar

Read only

0 Likes
10,893

Hi,

Check below link. He has explained some similar kind of requirement.

[;

Hope it helps.

Thanks,

Archana

Edited by: Archana Pawar on May 26, 2011 11:36 AM

Read only

0 Likes
10,893

Hi Archana,

Thats the same i did. I did commit after the FM call. But the problem persists. Thats the reason i have raised the question.

Thanks and Regards

Kumar

Read only

Former Member
0 Likes
10,893

Hi,

I know this is simple but is the value in itab-sgtxt not blank


gs_accchg-fdname = 'SGTXT'.
gs_accchg-newval = itab-sgtxt.           "<----------------
APPEND gs_accchg TO gt_accchg.
CLEAR gs_accchg.

Regards,

Ernesto.

Read only

Former Member
0 Likes
10,893

Hi,

I want to know what your passing itab-sgtxt. i think your passing the internal table of SGTXT. pass the WA-SGTXT 'work area'.

Regards,

Dhina..

Read only

Former Member
0 Likes
10,893

Hi,

Pass the required values to the table BKPF based on belnr (Document Number) and after that use commit work keyword.

sample code:

tables: bkpf.

parameters p_belnr like belnr_d.

start-of-selection.

select * from bkpf where belnr = p_belnr.

if sy-subrc = 0.

bkpf-sgtxt = 'Testing'.

modify bkpf.

commit work.

clear bkpf.

endif.

it will helps u.

Ram.

Read only

0 Likes
10,893

Thanks Emesto and Dhina,

I understand that the work area or the value is to be passed. I have tried hard coding from the begining of the post and

passing the value also.

It is sure not the problem of Value. I checked in debugging.. The problem exists.

Thanks Ram,

I need to change the text on the Items , not the header.

Thanks and Regards

Kumar

Read only

0 Likes
10,893

Hi,

I read on the internet (I am not sure about it because I couldn't find the FM documenation) that this FM cannot be used to change line item which has account type (BSEG-KOART) - 'S' (GL Account)?

Also On another Post I read it will not work if the Account Type is Different than D or K.

Is any of these your case?

Regards,

Ernesto.

Read only

Former Member
0 Likes
10,894

Hi,

Better try to pass the old value also..


gs_accchg-fdname = 'SGTXT'.
gs_accchg-oldval = "pass the old value.
gs_accchg-newval = itab-sgtxt.
APPEND gs_accchg TO gt_accchg.
CLEAR gs_accchg.

Regards,

Dhina..

Read only

0 Likes
10,893

Thanks you Emesto,

I found the same from my debugging that it doesnt allow for 'S'.

I would look for other options than this FM.

Thank you Dhina,

Please read in the post that i have passed the older value also. But as Emesto and me feel that the FM wouldn't work

for Type 'S'.

Thanks and Regards

Sampath

Read only

0 Likes
10,893

Hi,

if its not working try this function module FI_ITEMS_MASS_CHANGE but its not updating for all the line item. Please refer the code below.


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 = 'TEST19'.

* ITEM 7
select single
bukrs
belnr
gjahr
buzei
koart
umskz
bschl
mwart
mwskz
from bseg
into corresponding fields of it_buztab
where belnr = '0902001922' and
bukrs = '3160' and
gjahr = '2006' and
BUZEI = '007'.
if sy-subrc = 0.
APPEND it_buztab.
clear it_buztab.
endif.

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.
perform generate_message.
write : w_message.
else.
write : 'Updated successfully'.
ENDIF.
&---------------------------------------------------------------------
* & Form generate_message
&---------------------------------------------------------------------
FORM generate_message .
CLEAR W_message.

read table it_errtab index 1.
if sy-subrc 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = it_errtab-ERR-MSGID
lang = sy-langu
no = it_errtab-ERR-MSGNR
v1 = it_errtab-ERR-MSGV1
v2 = it_errtab-ERR-MSGV2
v3 = it_errtab-ERR-MSGV3
v4 = it_errtab-ERR-MSGV4
IMPORTING
msg = W_message
EXCEPTIONS
not_found = 1
OTHERS = 2.
endif.

ENDFORM. " generate_message

Regards,

Dhina..

Read only

0 Likes
10,893

Hi ,

refer this link first.

http://www.surfingincognito.com/index.php?q=aHR0cHM6Ly9mb3J1bXMuc2RuLnNhcC5jb20vdGhyZWFkLmpzcGE%2FdG...

click browse button after enter this website..i hope your requirement is resolve after see the link..

Regards,

Dhina..

Edited by: Dhina DMD on May 26, 2011 1:37 PM

Read only

0 Likes
10,892

Thank you very much Dhina. Not the Link but the code of mass items change has helped me.

Solved the problem.

I always believe in you experts solving my prblems. You never give up!!!!

Knowing the issue and helping isn't my appreciation. Not knowing and still trying to dig and find information and

help people on the forum is great which you experts always do!!!!

Thanks and Regards

Sampath

Read only

Former Member
0 Likes
10,892

Hi, FI_DOCUMENT_CHANGE is actually working, but error messages are not really detailed, so sometimes sy-subrc = 0 and yet no change happens.

I had a problem similar to yours and it depended in my case on KUNNR or LIFNR passed to the function.

The FM looks first in BKPF, and then in BSEG with LIFNR or KUNNR given.

If select in BSEG fails, the FM throws you out with no errors, and no changes happen.

so be careful with this value: I_KUNNR or I_LIFNR, one or other is actually obligatory in some cases, and must have the correct leading zeros.