SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_PO_RELEASE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
vga
Мастер
Мастер


Age: 160
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Fri Jun 04, 2010 9:35 am    Post subject: BAPI_PO_RELEASE Reply with quote

Release Purchase Orders

Code:
FORM release .
  DATA:
        ret2 TYPE TABLE OF bapiret2 WITH HEADER LINE,
        return TYPE TABLE OF bapireturn  WITH HEADER LINE.

  LOOP AT gt_ebeln.
    LOOP AT report_table INTO report_table_line
      WHERE ( status IS INITIAL OR status EQ icon_green_light )
        AND torel = 'X'.
      EXIT.
    ENDLOOP.
    CHECK sy-subrc IS INITIAL.
    CALL FUNCTION 'BAPI_PO_RELEASE'
      EXPORTING
        purchaseorder          = report_table_line-ebeln
        po_rel_code            = p_frgco
        no_commit              = 'X'
      TABLES
        return                 = return
      EXCEPTIONS
        authority_check_fail   = 1
        document_not_found     = 2
        enqueue_fail           = 3
        prerequisite_fail      = 4
        release_already_posted = 5
        responsibility_fail    = 6
        OTHERS                 = 7.
    report_table_line-status = icon_green_light.
    LOOP AT return.
      IF return-type EQ 'A' OR return-type EQ 'E'.
        report_table_line-status = icon_red_light.
      ELSEIF return-type EQ 'W' OR return-type EQ 'S'.
        report_table_line-status = icon_yellow_light.
      ENDIF.

      sy-msgid = return-log_no.
      sy-msgty = return-type.
      sy-msgno = return-log_msg_no.
      sy-msgv1 = return-message_v1.
      sy-msgv2 = return-message_v2.
      sy-msgv3 = return-message_v3.
      sy-msgv4 = return-message_v4.
      PERFORM add_message USING report_table_line-ebeln.
    ENDLOOP.
    LOOP AT return
       WHERE type = 'A' OR type = 'E'.
      EXIT.
    ENDLOOP.
    IF NOT sy-subrc IS INITIAL.  "No errors exists
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = 'X'
        IMPORTING
          return = ret2.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
        IMPORTING
          return = ret2.
    ENDIF.
    LOOP AT ret2.
      IF ret2-type EQ 'A' OR ret2-type EQ 'E'.
        report_table_line-status = icon_red_light.
      ELSEIF ret2-type EQ 'W' OR ret2-type EQ 'S'.
        report_table_line-status = icon_yellow_light.
      ENDIF.
      sy-msgid = ret2-id.
      sy-msgty = ret2-type.
      sy-msgno = ret2-number.
      sy-msgv1 = ret2-message_v1.
      sy-msgv2 = ret2-message_v2.
      sy-msgv3 = ret2-message_v3.
      sy-msgv4 = ret2-message_v4.
      PERFORM add_message USING report_table_line-ebeln.
    ENDLOOP.
    MODIFY report_table FROM report_table_line TRANSPORTING status
     WHERE ebeln = report_table_line-ebeln.
  ENDLOOP.
ENDFORM.                    " RELEASE
*&---------------------------------------------------------------------*
*&      Form  show_load_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TYPE   text
*      -->P_EBELN  text
*      -->P_EBELP  text
*----------------------------------------------------------------------*
FORM show_status USING p_ebeln.
  DATA: ls_messages TYPE ty_messages,
        l_is_messages.

  CALL FUNCTION 'MESSAGES_INITIALIZE'.
  LOOP AT gt_messages INTO ls_messages
    WHERE ebeln EQ p_ebeln
      AND NOT msgty IS INITIAL.
    CALL FUNCTION 'MESSAGE_STORE'
      EXPORTING
        arbgb = ls_messages-msgid
        msgty = ls_messages-msgty
        msgv1 = ls_messages-msgv1
        msgv2 = ls_messages-msgv2
        msgv3 = ls_messages-msgv3
        msgv4 = ls_messages-msgv4
        txtnr = ls_messages-msgno.
    l_is_messages = 'X'.
  ENDLOOP.
  IF NOT l_is_messages IS INITIAL.
    CALL FUNCTION 'MESSAGES_SHOW'.
  ENDIF.
ENDFORM.                    " show_load_status
*&---------------------------------------------------------------------*
*&      Form  add_message
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TYPE  text
*      -->P_EBELN  text
*      -->P_EBELP  text
*----------------------------------------------------------------------*
FORM add_message USING p_ebeln.
  DATA: ls_messages TYPE ty_messages.
  MOVE-CORRESPONDING sy TO ls_messages.
  ls_messages-ebeln = p_ebeln.
  APPEND ls_messages TO gt_messages.
ENDFORM.                    " add_message

*&---------------------------------------------------------------------*
*&      Form  refresh_messages
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->p_type  text
*----------------------------------------------------------------------*
FORM refresh_messages USING p_ebeln.
  DELETE gt_messages WHERE ebeln = p_ebeln.
ENDFORM.                    " refresh_messages

*&---------------------------------------------------------------------*
*&      Form  adj_message
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TYPE  text
*      -->P_EBELN  text
*      -->P_EBELP  text
*----------------------------------------------------------------------*
FORM adj_message USING p_ebeln.

  FIELD-SYMBOLS: <fs> TYPE ty_messages.

  LOOP AT gt_messages ASSIGNING <fs>
    WHERE ebeln IS INITIAL.
    <fs>-ebeln = p_ebeln.
  ENDLOOP.

ENDFORM.                    " adj_message

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.