09-18-2006 5:56 PM
Hi All,
Could you please let me know how to update data in field bseg-sgtxt.
any sample code .
answers are highly appreciated
Thanks
jog
09-18-2006 5:57 PM
09-18-2006 5:57 PM
09-18-2006 11:10 PM
Hi
Use function module CHANGE_DOCUMENT to change the text or Use tcdoe GGB1 and create a substitution rule and change the text if you have a standard text.
Nataraju
09-19-2006 1:40 AM
Hi,
I have a document and this field is blank and need to put some text in this field.
how to do this
Thanks
jog
09-19-2006 2:36 AM
Hi,
Use the transaction FB02 to update the BSEG-SGTXT if you want to do it manually.
Thanks,
Naren
09-19-2006 3:13 AM
Try Mass change option . You should be able to update without writing any code.
09-20-2006 6:48 PM
Hi Jog
I had a similar requirement. Below is the code it might be useful for you.
FORM change_item_text .
DATA : e_bkpf LIKE bkpf,
t_bkpf LIKE bkpf OCCURS 0 ,
t_bseg LIKE bseg OCCURS 0 WITH HEADER LINE,
t_bsec LIKE bsec OCCURS 0,
t_bset LIKE bset OCCURS 0,
t_bsed LIKE bsed OCCURS 0,
t_bkdf LIKE bkdf OCCURS 0.
DATA : BEGIN OF i_ref_doc OCCURS 0,
belnr LIKE bsad-belnr,
augbl LIKE bsad-augbl,
END OF i_ref_doc.
DATA : i_invoice_data LIKE i_ref_doc OCCURS 0 WITH HEADER LINE.
DATA : i_bkpf LIKE bkpf OCCURS 0 WITH HEADER LINE.
*Get the Accounting document number and SAP clearing document number
*based on the document number in the input file.
SELECT belnr augbl FROM bsad INTO TABLE i_ref_doc
FOR ALL ENTRIES IN itab WHERE
augbl = itab-belnr AND
bukrs = p_bukrs AND
gjahr = p_year.
*Get all documents from BKPF which is later used for validating
IF NOT i_ref_doc[] IS INITIAL.
SELECT * FROM bkpf INTO TABLE i_bkpf
FOR ALL ENTRIES IN i_ref_doc WHERE
belnr = i_ref_doc-belnr AND
bukrs = p_bukrs AND
gjahr = p_year.
ENDIF.
*Get only invoices
LOOP AT i_ref_doc.
IF i_ref_doc-belnr NE i_ref_doc-augbl.
APPEND i_ref_doc TO i_invoice_data.
ENDIF.
ENDLOOP.
REFRESH: i_ref_doc.
LOOP AT i_invoice_data.
*Check whether the document exists
READ TABLE i_bkpf WITH KEY belnr = i_invoice_data-belnr
gjahr = p_year
bukrs = p_bukrs.
IF sy-subrc = 0.
*Get header and line item data which is manipulated and passed to
*function module change document
CALL FUNCTION 'FI_DOCUMENT_READ1'
EXPORTING
i_docno = i_invoice_data-belnr
i_byear = p_year
i_compy = p_bukrs
IMPORTING
e_bkpf = e_bkpf
TABLES
t_bseg = t_bseg
t_bsec = t_bsec
t_bset = t_bset
EXCEPTIONS
NOT_FOUND = 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.
LOOP AT t_bseg WHERE shkzg = 'S'.
READ TABLE itab WITH KEY belnr = i_invoice_data-augbl.
IF sy-subrc = 0.
Change of line item text
MOVE itab-reason TO t_bseg-sgtxt.
MODIFY t_bseg.
CLEAR t_bseg.
ENDIF.
ENDLOOP.
APPEND e_bkpf TO t_bkpf.
IF NOT t_bseg[] IS INITIAL.
CALL FUNCTION 'CHANGE_DOCUMENT'
TABLES
t_bkdf = t_bkdf
t_bkpf = t_bkpf
t_bsec = t_bsec
t_bsed = t_bsed
t_bseg = t_bseg
t_bset = t_bset.
COMMIT WORK.
ENDIF.
CLEAR : t_bseg,t_bkpf,t_bsec,t_bsed,t_bset,i_ref_doc,e_bkpf.
REFRESH : t_bseg,t_bkpf,t_bsec,t_bsed,t_bset.
ENDIF.
ENDLOOP.
ENDFORM. " change_item_text
01-26-2007 5:40 PM
Hi Nataraju!
Thank you very much!! I was fighting with fm FI_DOCUMENT_CHANGE, which did not want to work! your entry helped me a lot. Now everything works as wished!
many thanks.
Ofelia