Archive

Author Archive

SAP ABAP : SELECT-OPTIONS et PARAMETERS dans dynpro – (SE80 / SE51)

February 10th, 2010 admin No comments

Je vous propose une solution pour ne plus hésiter entre la création de dynpro et un programme classique (écran de sélection généré).

Bien souvent on utilise un programme  classique pour pouvoir bénéficier des SELECT-OPTIONS et autres PARAMETERS très utiles pour la sélection des données, mais on oublie, à tord,  que l’on peut avoir exactement la même chose dans les dynpro. On peut allier facilement : Sélection de données des programmes et liberté graphique et fonctionnelle des dynpro.

Il suffit de gérer un sous-écran dans le dynpro et de déclarer le SELECTION-SCREEN comme SUBSCREEN.

Exemple :

REPORT  zsdspe89                                                    .

INCLUDE zsdspe89d.
INCLUDE zsdspe89f.
*– Définition de l’écran de sélection –*
SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
  SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-b01.
    SELECT-OPTIONS     : s_spbup  FOR s800-spbup OBLIGATORY.
  SELECTION-SCREEN END OF BLOCK bl1.
SELECTION-SCREEN END OF SCREEN 300.

*– Fin de la définition –*
CLASS lcl_app DEFINITION DEFERRED.

DATA : wo_app TYPE REF TO lcl_app.

*———————————————————————-*
*       CLASS lcl_app DEFINITION
*———————————————————————-*
*
*———————————————————————-*
CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
  PRIVATE SECTION.
ENDCLASS.                    “lcl_app DEFINITION

*———————————————————————-*
*       CLASS lcl_app IMPLEMENTATION
*———————————————————————-*
*
*———————————————————————-*
CLASS lcl_app IMPLEMENTATION.
ENDCLASS.                    “lcl_app IMPLEMENTATION

  INCLUDE zsdspe89_pbo.
  INCLUDE zsdspe89_pai.

START-OF-SELECTION.

  CALL SCREEN ’200′.

***************************************************

Dans le dynpro 200 on déclare le sous-ecran 300 :

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0200.
   CALL SUBSCREEN sub1 INCLUDING SY-REPID ‘0300′.
*
PROCESS AFTER INPUT.
   CALL SUBSCREEN sub1.
 MODULE USER_COMMAND_0200.

Categories: SAP Tags:

SAP MM – BAPI : BAPI_PO_CREATE1

February 3rd, 2010 admin No comments

Exemple d’utilisation de la BAPI :   BAPI_PO_CREATE1 pour la création d’une commande achat (Purchase order).

Je l’utilise depuis un avis QM pour automatiser la création du PO sur ordre de service afin de facturer des coûts de garantie. Pour info : La réception de ce PO est aussi automatisée via la barre d’activités de l’avis et la BAPI  :   BAPI_GOODSMVT_CREATE  .

 - Dans cet exemple on ne crée qu’un seul poste dans le PO

DATA : ws_poheader     TYPE bapimepoheader,
             ws_poheaderx     TYPE bapimepoheaderx,
             wt_poitem            TYPE TABLE OF bapimepoitem,
             ws_poitem            TYPE bapimepoitem,
             wt_poitemx          TYPE TABLE OF bapimepoitemx,
             ws_poitemx          TYPE bapimepoitemx,
             wt_poaccount     TYPE TABLE OF bapimepoaccount,
             ws_poaccount     TYPE bapimepoaccount,
             ws_poaccountx   TYPE bapimepoaccountx,
             wt_poaccountx   TYPE TABLE OF bapimepoaccountx,
             wt_pocondx         TYPE TABLE OF bapimepocondx,
             ws_pocondx        TYPE bapimepocondx,
             wt_pocond           TYPE TABLE OF bapimepocond,
             ws_pocond          TYPE bapimepocond,
             wt_return             TYPE TABLE OF bapiret2,
             ws_return            TYPE bapiret2.

  DATA : wv_waers TYPE bstwa,
              wv_netpr TYPE bprei.

  CONSTANTS : wc_avtf(4) VALUE ’AVTF’,
                           wc_604(10) VALUE ’0060411150′,
                           wc_1000(4) value ’1000′,
                           wc_gar(8)  value ’GARANTIE’.

*… Récupération des données

********************************************
*            Entete                        *
********************************************
  
CLEAR ws_poheader.
  ws_poheader-doc_type = ’NB’.
  ws_poheader-comp_code = wc_avtf.
  ws_poheader-purch_org = wc_avtf.
  ws_poheader-pur_group = ws_zq14-ekgrp.
  ws_poheader-vendor = ws_zq14-lifnr.
  ws_poheader-our_ref = i_viqmel-qmnum.
  ws_poheader-item_intvl = 00010.
  ws_poheader-currency = wv_waers.
  CLEAR ws_poheaderx.
  ws_poheaderx-doc_type = ’X’.
  ws_poheaderx-comp_code = ’X’.
  ws_poheaderx-purch_org = ’X’.
  ws_poheaderx-pur_group = ’X’.
  ws_poheaderx-vendor = ’X’.
  ws_poheaderx-our_ref = ’X’.
  ws_poheaderx-item_intvl = ’X’.
  ws_poheader-currency = ’X’.
*  ws_poheaderx-our_ref = ’X’.
**********************************************
*                Poste                       *
**********************************************
  CLEAR ws_poitem. REFRESH wt_poitem.
  CLEAR ws_poitemx. REFRESH wt_poitemx.
  ws_poitem-plant  = wc_1000.
  ws_poitemx-plant = ’X’.
  ws_poitem-stge_loc  = ws_zq14-lgort.
  ws_poitemx-stge_loc = ’X’.
  ws_poitem-matl_group  = wc_gar.
  ws_poitemx-matl_group = ’X’.
  ws_poitem-short_text  = text-607.
  ws_poitemx-short_text = ’X’.
  ws_poitem-po_item  = ’00010′.
  ws_poitemx-po_item = ’00010′.
  ws_poitemx-po_itemx = ’X’.
  ws_poitem-po_unit  = ’ST’.
  ws_poitemx-po_unit = ’X’.
  ws_poitem-quantity  = ’1′.
  ws_poitemx-quantity = ’X’.
  ws_poitem-acctasscat  = ’F’.
  ws_poitemx-acctasscat = ’X’.

  APPEND ws_poitem TO wt_poitem.
  APPEND ws_poitemx TO wt_poitemx.
*********************************************
*          Onglet imputation                *
*********************************************
 
 CLEAR ws_poaccount. REFRESH wt_poaccount.
  CLEAR ws_poaccountx. REFRESH wt_poaccountx.

  ws_poaccount-po_item  = ’00010′.
  ws_poaccountx-po_item = ’00010′.
  ws_poaccountx-po_itemx = ’X’.
  ws_poaccount-gl_account  = wc_604. 
  ws_poaccountx-gl_account = ’X’.
  ws_poaccount-orderid  = wv_aufnr. 
  ws_poaccountx-orderid = ’X’.
  ws_poaccount-co_area  = ’HVT’.
  ws_poaccountx-co_area = ’X’.
  ws_poaccount-bus_area = ’1′.
  ws_poaccountx-bus_area = ’X’.

  APPEND ws_poaccount  TO wt_poaccount.
  APPEND ws_poaccountx TO wt_poaccountx.

*********************************************
*           Conditions                      *
*********************************************
  CLEAR ws_pocond. REFRESH wt_pocond.
  CLEAR ws_pocondx. REFRESH wt_pocondx.

  ws_pocond-itm_number  = ’00010′.
  ws_pocondx-itm_number = ’00010′.
  ws_pocondx-itm_numberx = ’X’.
  ws_pocond-cond_value  = wv_netpr.
  ws_pocondx-cond_value = ’X’.
  ws_pocond-change_id  = ’I’.
  ws_pocondx-change_id = ’X’.
  ws_pocond-cond_type  = ’PB00′.
  ws_pocondx-cond_type = ’X’.

  APPEND ws_pocond TO wt_pocond.
  APPEND ws_pocondx TO wt_pocondx.

  CALL FUNCTION ‘BAPI_PO_CREATE1′
    EXPORTING
      poheader         = ws_poheader
      poheaderx        = ws_poheaderx
    IMPORTING
      exppurchaseorder = wv_ebeln
    TABLES
      return           = wt_return
      poitem           = wt_poitem
      poitemx          = wt_poitemx
      poaccount        = wt_poaccount
      poaccountx       = wt_poaccountx
      pocond           = wt_pocond
      pocondx          = wt_pocondx.

  CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
    EXPORTING
      wait = ’X‘.

Categories: SAP Tags: , ,