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 document and Ztable with BDC.

Former Member
0 Likes
493

Hi frns,

i need to implement a BDC program for update Document and Ztable1 using call transaction with recording FB02 and F-02 T-codes.

first i have to update the document by posting and finally update the ztable1.

Pls suggest me with relavant coding..

Thanks & regards

Sri....

Hi frns,

i need to implement a BDC program for update Document and Ztable1 using call transaction with recording FB02 and F-02 T-codes.

first i have to update the document by posting and finally update the ztable1.

Pls suggest me with relavant coding..

Thanks & regards

Sri....

2 REPLIES 2
Read only

Former Member
0 Likes
419

Hi,

Refer this sample code.... It may helpful..

DATA: file TYPE rlgrap-filename,

file1 TYPE dxfields-longpath.

PARAMETERS: p_file type filename-fileintern.

DATA:p_file1 LIKE filename-fileintern.

data: dataset1 TYPE dxfields-longpath.

DATA: record LIKE zabcd OCCURS 0 WITH HEADER LINE.

***Internal Table to store the output values of dynpro fields

DATA : wt_dynfields TYPE STANDARD TABLE OF dynpread,

wa_dynfields TYPE dynpread.

CONSTANTS: co_dynnr TYPE sy-dynnr VALUE '1000'.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

  • CLIENT = SY-MANDT

logical_filename = p_file

  • OPERATING_SYSTEM = SY-OPSYS

  • PARAMETER_1 = ' '

  • PARAMETER_2 = ' '

  • PARAMETER_3 = ' '

  • USE_PRESENTATION_SERVER = ' '

  • WITH_FILE_EXTENSION = ' '

  • USE_BUFFER = ' '

  • ELEMINATE_BLANKS = 'X'

IMPORTING

  • EMERGENCY_FLAG =

  • FILE_FORMAT =

file_name = file

EXCEPTIONS

file_not_found = 1

OTHERS = 2

.

file1 = file.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'

EXPORTING

i_location_flag = 'A'

  • i_server = '?'

i_path = file1 "'E:\usr\sap\put'

filemask = '.'

fileoperation = 'R'

IMPORTING

  • O_LOCATION_FLAG =

  • O_SERVER =

o_path = dataset1

  • ABEND_FLAG =

EXCEPTIONS

rfc_error = 1

error_with_gui = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

START-OF-SELECTION.

  • Read data from file on application server

OPEN DATASET dataset1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

MESSAGE 'ERROR' TYPE 'E'.

EXIT.

ENDIF.

  • Uploading data from application server text file to internal table

DO.

READ DATASET dataset1 INTO record.

APPEND record.

IF sy-subrc = 0.

INSERT zabcd FROM record.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET dataset1."gi_filedata.

IF sy-subrc = 0.

WRITE ' INSERTED SUCCESSFULLY'.

ELSE.

WRITE ' NOT INSERTED'.

ENDIF.

Regards,

K.Tharani.

Read only

Former Member
0 Likes
419

HI,

To update the document, try the sample program,

*----


  • DATA

*----


data fname(60) value 'sri.txt'.

data wi(30) type c.

*&----


*& OPENING A FILE

*&----


open dataset fname for output in text mode encoding default.

transfer 'Hello' to fname.

*&----


*& CLOSING A FILE

*&----


close dataset fname.

*&----


*& OPENING A FILE

*&----


open dataset fname for input in text mode encoding default.

do.

read dataset fname into wi.

write:/ wi.

translate wi to upper case.

write 😕 wi.

if sy-subrc = 0.

write : 'file is opened'.

endif.

if sy-subrc <> 0.

exit.

endif.

enddo.

*&----


*& CLOSING A FILE

*&----


close dataset fname.

This program shows the BDC part to update the Ztable.

CALL TRANSACTION METHOD.

CODE:

DATA : BEGIN OF ITAB OCCURS 0,

STR(255),

END OF ITAB.

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = 'C:\STAL.TXT'

FILETYPE = 'ASC'

TABLES

data_tab = ITAB.

DATA ITAB1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

LOOP AT ITAB.

SPLIT ITAB-STR AT ',' INTO ITAB1-KUNNR ITAB1-NAME1 ITAB1-ORT01 ITAB1-LAND1.

APPEND ITAB1.

ENDLOOP.

DATA JTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA KTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

LOOP AT ITAB1.

PERFORM PROGINFO USING 'SAPMZSTALINCT' '100'.

PERFORM FLDINFO USING 'WA-KUNNR' ITAB1-KUNNR.

PERFORM FLDINFO USING 'WA-NAME1' ITAB1-NAME1.

PERFORM FLDINFO USING 'WA-LAND1' ITAB1-LAND1.

PERFORM FLDINFO USING 'WA-ORT01' ITAB1-ORT01.

CALL TRANSACTION 'ZSTALINCT' USING JTAB MODE 'N' MESSAGES INTO KTAB.

ENDLOOP.

LOOP AT KTAB.

WRITE 😕 KTAB-TCODE, KTAB-DYNAME, KTAB-DYNUMB, KTAB-MSGTYP, KTAB-MSGNR, SY-SUBRC.

ENDLOOP.

FORM PROGINFO USING PROGNAME SCRNUM.

CLEAR JTAB.

REFRESH JTAB.

JTAB-PROGRAM = PROGNAME.

JTAB-DYNPRO = SCRNUM.

JTAB-DYNBEGIN = 'X'.

APPEND JTAB.

ENDFORM.

FORM FLDINFO USING FLDNAME FLDVAL.

CLEAR JTAB.

JTAB-FNAM = FLDNAME.

JTAB-FVAL = FLDVAL.

APPEND JTAB.

Hope this helps u.

Regards,

Arunsri