‎2011 May 25 4:35 PM
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
‎2011 May 26 12:12 PM
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..
‎2011 May 25 6:47 PM
‎2011 May 26 9:22 AM
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
‎2011 May 26 10:18 AM
Hi,
Did you try using 'BAPI_TRANSACTION_COMMIT'?
Thanks,
Archana
‎2011 May 26 10:29 AM
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
‎2011 May 26 10:36 AM
‎2011 May 26 10:55 AM
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
‎2011 May 26 11:22 AM
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.
‎2011 May 26 11:28 AM
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..
‎2011 May 26 11:48 AM
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.
‎2011 May 26 11:55 AM
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
‎2011 May 26 12:03 PM
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.
‎2011 May 26 12:12 PM
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..
‎2011 May 26 12:30 PM
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
‎2011 May 26 12:35 PM
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..
‎2011 May 26 12:37 PM
Hi ,
refer this link first.
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
‎2011 May 26 4:45 PM
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
‎2015 Nov 05 10:39 AM
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.