Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

replace production Order Text

Hi

I have requirement which replace the production order order text with sales order

TABLES:VBAP.

SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.

DATA: BEGIN OF ITAB_VBAP OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

END OF ITAB_VBAP.

DATA: BEGIN OF ITAB_FINAL OCCURS 0,

TDLINE LIKE TLINE-TDLINE,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

AUFNR LIKE CAUFV-AUFNR,

KDAUF LIKE CAUFV-KDAUF,

KDPOS LIKE CAUFV-KDPOS,

  • TDLINE1 LIKE TLINE-TDLINE,

END OF ITAB_FINAL.

DATA: INDEX1(10) TYPE N.

DATA: INDEX2(10) TYPE N.

INDEX1 = 1.

INDEX2 = 1.

DATA: NAME LIKE THEAD-TDNAME.

DATA: NAME1 LIKE THEAD-TDNAME..

DATA: ITAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA: JTAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA: ITAB1 LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA: JTAB1 LIKE TLINE OCCURS 0 WITH HEADER LINE.

SELECT VBELN POSNR FROM VBAP INTO CORRESPONDING FIELDS OF TABLE ITAB_VBAP WHERE VBELN IN S_VBELN .

SELECT AUFNR KDAUF KDPOS FROM CAUFV INTO CORRESPONDING FIELDS OF TABLE ITAB_FINAL FOR ALL ENTRIES IN ITAB_VBAP WHERE KDAUF = ITAB_VBAP-VBELN.

START-OF-SELECTION.

LOOP AT ITAB_VBAP.

CLEAR ITAB.

CONCATENATE ITAB_VBAP-VBELN ITAB_VBAP-POSNR INTO NAME.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = '0001'

LANGUAGE = SY-LANGU

NAME = NAME

OBJECT = 'VBBP'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = ITAB

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8

.

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 ITAB.

JTAB = ITAB.

APPEND JTAB.

ENDLOOP.

REFRESH ITAB.

ENDLOOP..

LOOP AT ITAB_VBAP.

READ TABLE JTAB INDEX INDEX1.

MOVE-CORRESPONDING JTAB TO ITAB_VBAP.

MODIFY ITAB_VBAP.

INDEX1 = INDEX1 + 1.

  • WRITE: / ITAB_VBAP-VBELN,ITAB_VBAP-POSNR,ITAB_VBAP-TDLINE.

ENDLOOP.

LOOP AT ITAB_FINAL.

READ TABLE ITAB_VBAP INDEX INDEX2.

IF ITAB_FINAL-KDAUF = ITAB_VBAP-VBELN.

MOVE ITAB_VBAP-TDLINE TO ITAB_FINAL-TDLINE.

MODIFY ITAB_FINAL.

INDEX2 = INDEX2 + 1.

ENDIF.

ENDLOOP.

INCLUDE BDCRECX1.

  • PARAMETERS: P_AUFNR LIKE AFPO-AUFNR.

DATA: BEGIN OF RECORD,

  • data element: AUFNR

AUFNR_001(012),

  • data element: FLG_OVIEW

FLG_OVIEW_002(001),

  • data element: GAMNG

GAMNG_003(017),

  • data element: CO_GMEIN

GMEIN_004(003),

  • data element: CO_GLTRP

GLTRP_005(010),

  • data element: CO_GSTRP

GSTRP_006(010),

  • data element: TERMKZ

TERKZ_007(001),

  • data element: FHORI

FHORI_008(003),

  • data element: VORGZ

VORGZ_009(003),

  • data element: SICHZ

SICHZ_010(003),

  • data element: FREIZ

FREIZ_011(003),

END OF RECORD.

      • End generated data section ***

START-OF-SELECTION.

PERFORM BDC_DYNPRO USING 'SAPLCOKO1' '0110'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'CAUFVD-AUFNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'CAUFVD-AUFNR'

RECORD-AUFNR_001.

PERFORM BDC_FIELD USING 'R62CLORD-FLG_OVIEW'

RECORD-FLG_OVIEW_002.

PERFORM BDC_DYNPRO USING 'SAPLCOKO1' '0115'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=TEXT'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'CAUFVD-GAMNG'.

PERFORM BDC_FIELD USING 'CAUFVD-GAMNG'

RECORD-GAMNG_003.

PERFORM BDC_FIELD USING 'CAUFVD-GMEIN'

RECORD-GMEIN_004.

PERFORM BDC_FIELD USING 'CAUFVD-GLTRP'

RECORD-GLTRP_005.

PERFORM BDC_FIELD USING 'CAUFVD-GSTRP'

RECORD-GSTRP_006.

PERFORM BDC_FIELD USING 'CAUFVD-TERKZ'

RECORD-TERKZ_007.

PERFORM BDC_FIELD USING 'CAUFVD-FHORI'

RECORD-FHORI_008.

PERFORM BDC_FIELD USING 'CAUFVD-VORGZ'

RECORD-VORGZ_009.

PERFORM BDC_FIELD USING 'CAUFVD-SICHZ'

RECORD-SICHZ_010.

PERFORM BDC_FIELD USING 'CAUFVD-FREIZ'

RECORD-FREIZ_011.

PERFORM BDC_DYNPRO USING 'SAPLCOKO1' '0115'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BU'.

CALL TRANSACTION 'CO02' USING BDCDATA MODE 'A' UPDATE 'S'.

with this code how to replace the long text in production order with sales order

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question