본문 바로가기
ABAP

BDC Program Logic

by clode 2023. 3. 1.
728x90
반응형

자세한 로직 설명은 이전 BDC 글 참고.

  DATA: LV_INDEX TYPE SY-INDEX,
        LT_DISP  TYPE TABLE OF TYS_DISP.

  DATA: LT_BDC TYPE TABLE OF BDCDATA,
        LT_MSG TYPE TABLE OF BDCMSGCOLL,
        LS_MSG LIKE LINE OF LT_MSG.

  DATA: LS_OPT     TYPE CTU_PARAMS,
        LV_MOVE    LIKE CTU_PARAMS-DISMODE,
        LV_MESSAGE LIKE BAPIRETURN-MESSAGE.


* 옵션 설정
      LS_OPT-DISMODE = GC_N.
      LS_OPT-UPDMODE = GC_A.
      LS_OPT-DEFSIZE = GC_X.

* bdc 프로세스 시작
      PERFORM BDC_DATA TABLES LT_BDC
                        USING:  SHDB에서 딴 레코딩

* 트랜잭션 호출
      CALL TRANSACTION 'VL02N'
              USING LT_BDC
              OPTIONS FROM LS_OPT
              MESSAGES INTO LT_MSG.

* 메세지INT 마지막 라인 읽기
      CLEAR: LV_INDEX.
      DESCRIBE TABLE LT_MSG LINES LV_INDEX.
      READ TABLE LT_MSG INTO LS_MSG INDEX LV_INDEX.

      CHECK SY-SUBRC = 0.

* 메세지 생성 펑션
      CALL FUNCTION 'MESSAGE_TEXT_BUILD'
        EXPORTING
          MSGID               = LS_MSG-MSGID
          MSGNR               = LS_MSG-MSGNR
          MSGV1               = LS_MSG-MSGV1
          MSGV2               = LS_MSG-MSGV2
          MSGV3               = LS_MSG-MSGV3
          MSGV4               = LS_MSG-MSGV4
        IMPORTING
          MESSAGE_TEXT_OUTPUT = LV_MESSAGE.

      IF LS_MSG-MSGID EQ 'VL' AND LS_MSG-MSGNR EQ '311'.
        COMMIT WORK AND WAIT.
        LS_DISP-KODAT = GV_DATE.
        MODIFY GT_DISP FROM LS_DISP TRANSPORTING KODAT
                                    WHERE VBELN = LS_DISP-VBELN.
        MESSAGE S007. "WITH GV_MESSAGE.

      ELSE.
        ROLLBACK WORK.
        MESSAGE S000 WITH LV_MESSAGE DISPLAY LIKE GC_E.
        RETURN.
      ENDIF.

      CLEAR: LS_DISP, LT_BDC, LS_OPT, LT_MSG, LS_MSG.



ENDFORM.
*&---------------------------------------------------------------------*
*& Form BDC_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&      --> P_
*&      --> P_
*&      --> P_
*&---------------------------------------------------------------------*
FORM BDC_DATA TABLES PT_BDC
               USING PV_CHECK PV_NAME PV_VALUE.
  DATA: LS_BDC TYPE BDCDATA.

  CLEAR: LS_BDC.
  IF PV_CHECK EQ 'X'.
    LS_BDC-PROGRAM = PV_NAME.
    LS_BDC-DYNPRO = PV_VALUE.
    LS_BDC-DYNBEGIN = PV_CHECK.
  ELSE.
    LS_BDC-FNAM = PV_NAME.
    LS_BDC-FVAL = PV_VALUE.
  ENDIF.

  APPEND LS_BDC TO PT_BDC.
ENDFORM.
728x90
반응형

'ABAP' 카테고리의 다른 글

프로그램 호출시 새창으로 호출하기 (ABAP4_CALL_TRANSACTION)  (0) 2023.03.01
ALV cell edit/color  (0) 2023.03.01
MESSAGE  (0) 2023.03.01
ALV Refresh시 Layout 재설정 (SET_FRONTEND_LAYOUT)  (0) 2023.03.01
Pop-up ALV  (0) 2023.02.27

댓글