Application Development 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: 

TEXTS IN BDC!!

Former Member
0 Kudos

REPORT ZRV_VA01_TRIAL

NO STANDARD PAGE HEADING LINE-SIZE 255.

DATA: BEGIN OF T_RECORD OCCURS 0,

AUART LIKE VBAK-AUART,

VBELN LIKE VBAK-VBELN,

KUNNR LIKE KNA1-KUNNR,

KUNNR1 LIKE KNA1-KUNNR,

BSTKD LIKE VBKD-BSTKD,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

ZMENG LIKE VBAP-ZMENG,

END OF T_RECORD.

DATA : BEGIN OF T_TEXT OCCURS 0,

TDNAME LIKE THEAD-TDNAME,

TEXT LIKE TLINE-TDLINE,

END OF T_TEXT.

DATA : BEGIN OF TTHEAD1 OCCURS 0,

TDOBJECT LIKE THEAD-TDOBJECT,

TDNAME LIKE THEAD-TDNAME,

TDID LIKE THEAD-TDID,

TDSPRAS LIKE THEAD-TDSPRAS,

END OF TTHEAD1.

*DATA : INDEX LIKE I .

DATA : BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0 WITH HEADER LINE,

MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,

G_LANG LIKE SY-LANGU.

DATA : T_THEAD TYPE STANDARD TABLE OF THEAD INITIAL SIZE 0 WITH HEADER LINE,

T_TLINE TYPE STANDARD TABLE OF TLINE INITIAL SIZE 0 WITH HEADER LINE.

DATA : V_TDNAME(70).

CLEAR V_TDNAME.

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\sirisham\Desktop\VA01-BDC.txt'

FILETYPE = 'DAT'

TABLES

DATA_TAB = T_RECORD

ENDIF.

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\sirisham\Desktop\va01-bdc-text.txt'

FILETYPE = 'DAT'

TABLES

DATA_TAB = T_TEXT

CALL FUNCTION 'CONVERSION_EXIT_ISOLA_INPUT'

EXPORTING

INPUT = 'E'

IMPORTING

OUTPUT = G_LANG

LOOP AT T_RECORD.

CONCATENATE T_RECORD-VBELN T_RECORD-POSNR INTO V_TDNAME.

MOVE V_TDNAME TO TTHEAD1-TDNAME.

TTHEAD1-TDOBJECT = 'VBBP'.

TTHEAD1-TDID = '0001'.

TTHEAD1-TDSPRAS = G_LANG.

APPEND TTHEAD1.

ENDLOOP.

START-OF-SELECTION.

LOOP AT T_RECORD.

REFRESH BDCDATA.

CLEAR BDCDATA .

PERFORM BDC_DYNPRO USING 'SAPMV45A' '0101'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'VBAK-AUART'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.

PERFORM BDC_FIELD USING 'VBAK-AUART' T_RECORD-AUART.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.

PERFORM BDC_FIELD USING 'VBAK-VBELN' T_RECORD-VBELN.

PERFORM BDC_FIELD USING 'KUAGV-KUNNR' T_RECORD-KUNNR.

PERFORM BDC_FIELD USING 'KUWEV-KUNNR' T_RECORD-KUNNR1.

PERFORM BDC_FIELD USING 'VBKD-BSTKD' T_RECORD-BSTKD.

PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' '07/41'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=CHOO'.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.

PERFORM BDC_FIELD USING 'VBAP-POSNR(01)' T_RECORD-POSNR.

PERFORM BDC_FIELD USING 'RV45A-MABNR(01)' T_RECORD-MATNR.

PERFORM BDC_FIELD USING 'VBAP-ZMENG(01)' T_RECORD-ZMENG.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=PTEX_SUB'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'VBAP-POSNR(01)'.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '4003'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/EBACK'.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '4001'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=PTEX_SUB'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'VBAP-POSNR(01)'.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '4003'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=SICH'.

PERFORM BDC_DYNPRO USING 'SAPLSPO2' '0101'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=OPT1'.

LOOP AT TTHEAD1.

CLEAR TTHEAD1 .

REFRESH TTHEAD1.

READ TABLE TTHEAD1 WITH KEY TDNAME = TTHEAD1-TDNAME.

MOVE-CORRESPONDING TTHEAD1 TO T_THEAD .

APPEND T_THEAD .

LOOP AT T_TEXT WHERE TDNAME = T_THEAD-TDNAME .

CLEAR T_TLINE.

MOVE T_TEXT-TEXT TO T_TLINE-TDLINE .

APPEND T_TLINE.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = T_THEAD

INSERT = ' '

SAVEMODE_DIRECT = 'X'

TABLES

LINES = T_TLINE

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CALL FUNCTION 'COMMIT_TEXT' .

ENDLOOP .

ENDLOOP .

CALL TRANSACTION 'VA01' USING BDCDATA

MODE 'A'

UPDATE 'S'

MESSAGES INTO MESSTAB.

ENDLOOP.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.

THIS MY CODE.IT HAS TO LOAD THE TEXT INTO THE TRANSACTION.WHEN I RUN THE BDC...........FOR A SALES ORDER IT IS WRITTING THE TEXT FOR ALL THE SALES ORDERS.......PLEASE DO GIVE ME A SOLUTION...............

THANKING U IN ANTICIPATION.

REGARDS,

SUPRIYA MATTA.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi.

you are not refreshing the tabel T_TLINE.

Regards,

Satya.

5 REPLIES 5

former_member181962
Active Contributor
0 Kudos

Whats are your trying to do here?

"LOOP AT TTHEAD1.

CLEAR TTHEAD1 .

REFRESH TTHEAD1."...?

remove the clear and refresh statements.

Regards,

Ravi

0 Kudos

FOR THE FIRST TIME IT IS WRITING THE TEXT FOR THE FIRST RECORD,BUT THE SECOND TIME IT IS WRITING THE TEXTS WHICH R ASSIGNED TO TO THE OTHER RECORDS??????????HELP.............

THANKS FOR THE REPLY.

Former Member
0 Kudos

Hi.

you are not refreshing the tabel T_TLINE.

Regards,

Satya.

0 Kudos

YES I REFRESHING TLINE.

Former Member
0 Kudos

THANK A LOT SATYANARAYANA........IT SOLVED THE PROBLEM...........THANKS A LOT.