[ABAP] BAPI_PO_CREATE1

Jubami·2023년 8월 18일
0

SAP 

목록 보기
6/13

BAPI_PO_CREATE1 사용법

ME23N과 비교해서 알아보기

헤더

  • 활용 데이터
X) 표준 구매오더를 생성할때, 구매정보레코드가 존재할때

  

  data: ls_poheader     type bapimepoheader,

        ls_poheaderx   type bapimepoheaderx.

  data: lv_po_number   like bapimepoheader-po_number.

  data: lt_return       type table of bapiret2,

        ls_return       like line of lt_return,

        lt_poitem       type table of bapimepoitem,

        ls_poitem       like line of lt_poitem,

        lt_poitemx     type table of bapimepoitemx,

        ls_poitemx     like line of lt_poitemx,

        lt_poschedule   type table of bapimeposchedule,

        ls_poschedule   like line of lt_poschedule,

        lt_poschedulex type table of bapimeposchedulx,

        ls_poschedulex like line of lt_poschedulex.

  data:  l_matnr    type matnr.

 

  refresh: lt_return,  lt_poitem,  lt_poitemx,  lt_poschedule,

           lt_poschedulex.

  clear: ls_return,  ls_poitem,  ls_poitemx,  ls_poschedule,

         ls_poschedulex.

  clear: ls_poheader,  ls_poheaderx,  lv_po_number.

 

  if  ls_poheader is initial.

      ls_poheader-comp_code = '회사코드'.

      ls_poheader-doc_type  = '구매문서유형 ex) NB'.

      ls_poheader-vendor    = '공급업체'.

      ls_poheader-purch_org = '구매조직'.

      ls_poheader-pur_group = '구매그룹'.

      ls_poheader-doc_date  = '생성일자'.

 

      ls_poheaderx-comp_code = 'X'.

      ls_poheaderx-doc_type  =  'X'.

      ls_poheaderx-vendor    =  'X'.

      ls_poheaderx-purch_org =  'X'.

      ls_poheaderx-pur_group =  'X'.

      ls_poheaderx-doc_date  =  'X'.

  endif.

아이템

  • 세금코드
'품목번호는 LOOP문으로 10씩 증가시켜 ls_poitem에 append 할 수 있음

    ls_poitem-po_item    = '품목번호'.

 

'자재번호에 자릿수만큼 0추가(S4하나 이전버전)

    call function 'CONVERSION_EXIT_ALPHA_INPUT'

              exporting
                   input  = '자재번호'.
              importing
                   output =  l_matnr.
                   
    ls_poitem-material   = l_matnr.
    ls_poitem-plant      = '플랜트'.
    ls_poitem-stge_loc   = '저장위치'.
    ls_poitem-quantity   = '수량'.
    ls_poitem-tax_code   = '세금코드'.

 

    if  반품.
      ls_poitem-ret_item = 'X'.
    endif.
    append ls_poitem to lt_poitem.
 
    ls_poitemx-po_item  =  '품목번호'.
    ls_poitemx-material =  'X'.
    ls_poitemx-plant    =  'X'.
    ls_poitemx-stge_loc =  'X'.
    ls_poitemx-quantity =  'X'.

 
    if 반품.
      ls_poitemx-ret_item = 'X'.
    endif.
    append ls_poitemx to lt_poitemx.

    ls_poschedule-po_item       = '품목번호'.
    ls_poschedule-sched_line    = '0001'.
    ls_poschedule-delivery_date = '납품일'.
    append ls_poschedule to lt_poschedule.

 

    ls_poschedulex-po_item       = '품목번호'.
    ls_poschedulex-sched_line    = '0001'.
    ls_poschedulex-delivery_date = 'X'.
    append ls_poschedulex to lt_poschedulex.

 
    call function 'BAPI_PO_CREATE1'

      exporting

        poheader         = ls_poheader

        poheaderx        = ls_poheaderx

        no_authority     =  'X'

      importing

        exppurchaseorder = lv_po_number

      tables

        return           = lt_return

        poitem           = lt_poitem

        poitemx          = lt_poitemx

        poschedule       = lt_poschedule

        poschedulex      = lt_poschedulex.

 

    if  lv_po_number is not initial.

      call function 'BAPI_TRANSACTION_COMMIT'

        exporting

          wait =  'X'

      wait up to 1 seconds.

    endif.                
    ```
profile
LV.1 아밥퍼

1개의 댓글

comment-user-thumbnail
2023년 8월 18일

감사합니다. 이런 정보를 나눠주셔서 좋아요.

답글 달기