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

List of Open Purchase Orders



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Mar 27, 2010 12:56 am    Post subject: List of Open Purchase Orders Reply with quote

Code:
*-----------------------------------------------------------------------
* Programe Name : ZMM_OPENPO_DETAILS
* PO open if GRN not done for full quantity or
* deliv. completed/final inv indicator not ticked
* Net PO amount : Basic Price
* Gross PO amount : Includes Excise & Transp charges (Total price)
* Net Pending Amount : Basic Pending amount
* Gross Pending amount : Gross Pending amount (Calculated via condition
* amount * Undelv qty)
* ACCOUNT ASSIG. CATEGORY : A -FOR ASSET
* Q- FOR PROJECT
*-----------------------------------------------------------------------

REPORT zmm_openpo_details LINE-SIZE 200 NO STANDARD PAGE HEADING.

TABLES : ekko, ekpo, ekbe, eket, ekkn, lfa1, konv .
*For ALV display
TYPE-POOLS: slis.
DATA: g_repid LIKE sy-repid,
gs_print TYPE slis_print_alv,
gt_list_top_of_page TYPE slis_t_listheader,
gt_events TYPE slis_t_event,
gt_sort TYPE slis_t_sortinfo_alv,
gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_variant LIKE disvariant,
fieldcat_ln LIKE LINE OF gt_fieldcat,
col_pos TYPE i.
DATA : BEGIN OF itab OCCURS 0,
bedat LIKE ekko-bedat,
ebeln LIKE ekko-ebeln, "PO Number
ekorg LIKE ekko-ekorg, " Pur Org
ekgrp LIKE ekko-ekgrp, " Pur Group
lifnr LIKE ekko-lifnr, "VENDOR NumbeR
ven_name LIKE lfa1-name1,
gsber LIKE ekkn-gsber,
waers LIKE ekko-waers, " CURRency
wkurs LIKE ekko-wkurs, " EXCH RATE
rlwrt LIKE ekko-rlwrt, " TOTAL VALUE
ebelp LIKE ekpo-ebelp, " Item Number
matnr LIKE ekpo-matnr, " Material NumbeR
werks LIKE ekpo-werks, " PLANT
netval LIKE ekpo-netwr, " NET PO AMT
grsval LIKE ekpo-effwr, " GROSS PO AMT
netpen LIKE ekpo-brtwr, " NET PENDING AMT
grspen LIKE ekpo-netwr, " GROSS PENDING AMT
sch_qty LIKE eket-menge, " Ordered Qty
del_qty LIKE eket-wemng, " Recvd Qty
undel_qty LIKE eket-wemng,
brtwr LIKE ekpo-brtwr, " Gross PO value
dmbtr LIKE ekbe-dmbtr,
dwn_py LIKE ekbe-dmbtr,
celcol TYPE slis_t_specialcol_alv, "FOR COLOR
END OF itab.
DATA : BEGIN OF i_ekko OCCURS 0.
        INCLUDE STRUCTURE ekko. " Header Data
DATA : END OF i_ekko.
DATA : BEGIN OF i_ekpo OCCURS 0.
        INCLUDE STRUCTURE ekpo. " PO DETAILS
DATA : END OF i_ekpo.
DATA : BEGIN OF i_eket OCCURS 0.
        INCLUDE STRUCTURE eket. " SCHEDULE LINES
DATA : END OF i_eket.
DATA : BEGIN OF i_ekbe OCCURS 0.
        INCLUDE STRUCTURE ekbe. " PO HISTORY
DATA : END OF i_ekbe.
DATA : BEGIN OF itab2 OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA : END OF itab2.
DATA: BEGIN OF itab_fieldcat OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab_fieldcat.
DATA : totvl LIKE ekpo-netwr,
totnetvl LIKE ekpo-netwr,
totgrsvl LIKE ekpo-brtwr,
totnetpn LIKE ekpo-netpr,
totgrspn LIKE ekpo-brtwr,
totunqty LIKE ekpo-menge,
val1 LIKE ekbe-dmbtr,
val2 LIKE ekbe-dmbtr,
val3 LIKE ekbe-dmbtr,
dwn_py1 LIKE ekbe-dmbtr,
dwn_py2 LIKE ekbe-dmbtr,
dwnpy LIKE ekbe-dmbtr,
v_kschl LIKE konv-kschl,
v_kbetr LIKE konv-kwert.
DATA: w_variant LIKE disvariant.
*DEFINE FOR COLORED COLUMNS
DATA: id_color TYPE c.
DATA: celcol1 TYPE slis_specialcol_alv.
DATA: syprindex TYPE i VALUE 1.
REFRESH: i_ekko, i_ekpo.
REFRESH i_eket.
REFRESH i_ekbe.
REFRESH itab.
REFRESH itab2.

INITIALIZATION.
  g_repid = sy-repid.

AT SELECTION-SCREEN.
*CODE ADDED TO Prevent user from submitting jobs more than once
  TABLES: tbtco. "Job status overview table
  DATA: t_jobcnt(1) TYPE n,
  t_sdluname LIKE tbtco-sdluname,
  t_strtdate LIKE tbtco-strtdate,
  t_strttime LIKE tbtco-strttime.
  SELECT * FROM tbtco WHERE jobname = sy-repid
  AND strtdate = sy-datum
  AND status = 'R'.
    t_jobcnt = t_jobcnt + 1.
    IF t_jobcnt = 1.
      t_sdluname = tbtco-sdluname.
      t_strtdate = tbtco-strtdate.
      t_strttime = tbtco-strttime.
    ENDIF.
  ENDSELECT.
  IF sy-subrc = 0.
    IF t_jobcnt GT 1.
      MESSAGE ID 'ZABAP' TYPE 'E' NUMBER '005'
      WITH t_strtdate t_strttime.
    ENDIF.
  ENDIF.

START-OF-SELECTION.
  SELECTION-SCREEN SKIP 1.
  SELECTION-SCREEN BEGIN OF BLOCK v-1 WITH FRAME TITLE text-025.
  SELECT-OPTIONS:
  plant FOR ekpo-werks, " PLANT
  doc_no FOR ekko-ebeln, " PO Number
  doc_dt FOR ekko-bedat, " posting date
  vendor FOR ekko-lifnr, " VENDOR NumbeR
  doc_type FOR ekko-bstyp DEFAULT 'F', " FOR POs
  acc_assg FOR ekpo-knttp.
  " DEFAULT 'A'. " ACC ASSGN CATEGORY
  SELECTION-SCREEN SKIP 1.
  SELECTION-SCREEN END OF BLOCK v-1.
  SELECTION-SCREEN SKIP 1.
* Select Header iformation FOR DOcument category - PO.
  SELECT * APPENDING CORRESPONDING FIELDS OF TABLE i_ekko
  FROM ekko WHERE ebeln IN doc_no
  AND bedat IN doc_dt
  AND lifnr IN vendor
  AND bstyp = 'F'.
  SORT i_ekko BY ebeln lifnr.
  LOOP AT i_ekko.
    CLEAR i_ekpo.
    AT NEW ebeln.
      CLEAR itab.
      CLEAR itab2.
    ENDAT.
* Selecting the relevant PO DETAILS FROM EKPO
    SELECT * FROM ekpo INTO i_ekpo
    WHERE ebeln EQ i_ekko-ebeln
    AND bstyp EQ i_ekko-bstyp
    AND werks IN plant
    AND knttp IN acc_assg.
      IF sy-subrc = 0.
        APPEND i_ekpo.
      ENDIF.
    ENDSELECT.
    SORT i_ekpo BY ebeln ebelp.
    totnetvl = 0.
    totgrsvl = 0.
    totunqty = 0.
    totnetpn = 0.
    totgrspn = 0.
    CLEAR i_ekpo.
    LOOP AT i_ekpo WHERE ebeln = i_ekko-ebeln.
      val1 = 0.
      val2 = 0.
      val3 = 0.
      totvl = 0.
      dwn_py1 = 0.
      dwn_py2 = 0.
      dwnpy = 0.
* FIRST CHECK FOR DELETION INDICATOR & DELIVERY COMPLETED INDICATOR.
      IF i_ekpo-loekz NE 'L' AND i_ekpo-loekz NE 'S'
       AND i_ekpo-elikz NE 'X'
* for final invoice indicator
      AND i_ekpo-erekz NE 'X'.
* SUM NET ORDER VALUE ITEM WISE FOR TOTAL NET PO PRICE
        AT END OF ebelp.
          SUM.
          totnetvl = totnetvl + i_ekpo-netwr.
          totgrsvl = totgrsvl + i_ekpo-effwr.
        ENDAT.
* Transfer TOTAL NET PO PRICE TO ITAB
        itab-netval = totnetvl.
* Convert PO VALUE TO INR IF IN FOREIGN CURRENCY
* MULTIPLY BY CONVESION RATE
        IF i_ekko-waers NE 'INR'.
          itab-netval = i_ekko-wkurs * totnetvl.
        ENDIF.
* CHECK WHETHER MATERIAL OR SERVICE PO.
        IF i_ekpo-pstyp EQ 0. " STANDARD PO
* SELECT scheduling line agreements from EKET
          CLEAR i_eket.
          SELECT * FROM eket INTO i_eket WHERE ebeln EQ i_ekpo-ebeln
          AND ebelp EQ i_ekpo-ebelp.
            IF sy-subrc = 0.
              APPEND i_eket.
            ENDIF.
          ENDSELECT.
* FOR MATERIAL PO - CHECK QUANTITY FROM EKET
* COMPARE SCHEDULED QTY WITH DELIVERED QTY,
* IF LESS THAN PO - OPEN PO
          LOOP AT i_eket WHERE ebeln = i_ekpo-ebeln
           AND ebelp EQ i_ekpo-ebelp.
* GET DOWN PAYMENT FROM PO HISTORY WHEN BEWTP = A
* CHECK DEBIT/CREDIT INDICATOR
            SELECT * FROM ekbe WHERE ebeln EQ i_eket-ebeln.
              IF ekbe-vgabe = 4 AND ekbe-bewtp = 'A'. "DOWN PAYMENT
                IF ekbe-shkzg = 'S'. "CREDIT/DEBIT INDICATOR
                  dwn_py1 = dwn_py1 + ekbe-dmbtr.
                ELSEIF ekbe-shkzg = 'H'.
                  dwn_py2 = dwn_py2 + ekbe-dmbtr.
                ENDIF.
                itab-dwn_py = dwn_py1 - dwn_py2.
              ENDIF.
            ENDSELECT.
* CHECK DELIVERED QTY WITH SCHEDULED QTY
            IF i_eket-wemng LT i_eket-menge.
              val1 = 0.
              val2 = 0.
              val3 = 0.
              totvl = 0.
              SELECT SINGLE * FROM lfa1 WHERE lifnr = i_ekko-lifnr.
              SELECT SINGLE * FROM ekkn WHERE ebeln = i_ekpo-ebeln.
              itab-bedat = i_ekko-bedat.
              itab-ebeln = i_ekko-ebeln.
              itab-ekorg = i_ekko-ekorg.
              itab-ekgrp = i_ekko-ekgrp.
              itab-lifnr = i_ekko-lifnr.
              itab-ven_name = lfa1-name1.
              itab-gsber = ekkn-gsber.
              itab-ekorg = i_ekko-ekorg.
              itab-ekgrp = i_ekko-ekgrp.
              itab-waers = i_ekko-waers.
              itab-wkurs = i_ekko-wkurs.
              itab-rlwrt = i_ekko-rlwrt.
              itab-ebelp = i_eket-ebelp.
              itab-matnr = i_ekpo-matnr.
              itab-werks = i_ekpo-werks.
              itab-sch_qty = i_eket-menge.
              itab-del_qty = i_eket-wemng.
              val1 = itab-sch_qty - itab-del_qty.
              totunqty = totunqty + val1.
              itab-undel_qty = totunqty.
* Get FREIGHT & TRANSPORTATION CHARGES FROM Conditions
* TRANSACTION DATA
              SELECT kschl kwert INTO (v_kschl, v_kbetr)
              FROM konv
              WHERE knumv = i_ekko-knumv
              AND kposn = i_ekpo-ebelp.
                IF ( v_kschl = 'FRC1' OR v_kschl = 'ZIND' OR
                v_kschl = 'ZOTH' OR v_kschl = 'ZINS' OR
                v_kschl = 'ZAGN' OR v_kschl = 'ZBAN' OR
                v_kschl = 'ZCWC' OR v_kschl = 'ZCLR' OR
                v_kschl = 'ZCON' OR v_kschl = 'ZLCC' OR
                v_kschl = 'ZPRT' ).
                  val3 = val3 + v_kbetr.
                ENDIF.
* IF PO CURRENCY NOT INR- ADD CUSTOM DUTY & MODVATABLE AMT
                IF i_ekko-waers NE 'INR' AND v_kschl = 'ZOA1' OR
                v_kschl = 'ZCDM' OR v_kschl = 'ZCDN'.
                  val3 = val3 + v_kbetr.
                ELSEIF v_kschl = 'ZLAN'.
* DEDUCT LANDING CHARGES
                  val3 = val3 - v_kbetr.
                ENDIF.
              ENDSELECT.
              totgrsvl = totgrsvl + val3.
              itab-grsval = totgrsvl. " GROSS PO VALUE
* SUM PENDING NET VALUE OF PO
              val2 = val1 * i_ekpo-netpr.
              totnetpn = totnetpn + val2.
              itab-netpen = totnetpn.
* SUM PENDING GROSS VALUE OF PO
              totvl = i_ekpo-effwr + val3.
* FOR CONDITION NET AMOUNT DIVIDE TOT AMT BY SCH QTY
              val2 = ( totvl / itab-sch_qty ).
* FOR PENDING AMT MULTIPLY NET CONDition AMT BY UNDELV QTY
              val3 = val2 * val1.
              totgrspn = totgrspn + val3.
              itab-grspen = totgrspn.
              IF i_ekko-waers NE 'INR'. " MULTIPLY BY CONVERT RATE
                itab-grsval = i_ekko-wkurs * totgrsvl.
                itab-netpen = i_ekko-wkurs * totnetpn.
                itab-grspen = i_ekko-wkurs * totgrspn.
              ENDIF.
              APPEND itab.
            ENDIF.
          ENDLOOP.
        ELSEIF i_ekpo-pstyp EQ 9. " FOR SERVICE PO
* CHECK PO AMT FROM PO HISTORY - EKBE
          CLEAR i_ekbe.
          SELECT * FROM ekbe INTO i_ekbe
          WHERE ebeln EQ i_ekpo-ebeln AND ebelp EQ i_ekpo-ebelp.
            IF sy-subrc = 0.
              APPEND i_ekbe.
            ENDIF.
          ENDSELECT.
          val1 = 0.
          val2 = 0.
          totvl = 0.
          dwn_py1 = 0.
          dwn_py2 = 0.
          dwnpy = 0.
          LOOP AT i_ekbe WHERE ebeln = i_ekko-ebeln.
            IF i_ekbe-vgabe = 1. " ONLY GOODS RECEIPT
* ADD AMOUNT OF GOODS RECEIPT
              IF i_ekbe-shkzg = 'S'. " CREDIT/DEBIT INDICATOR
                val1 = val1 + i_ekbe-dmbtr.
              ELSEIF i_ekbe-shkzg = 'H'.
                val2 = val2 + i_ekbe-dmbtr.
              ENDIF.
              totvl = val1 - val2.
            ENDIF.
            IF i_ekbe-bewtp = 'A'. " DOWN PAYMENT
              IF i_ekbe-shkzg = 'S'. " CREDIT/DEBIT INDICATOR
                dwn_py1 = dwn_py1 + i_ekbe-dmbtr.
              ELSEIF i_ekbe-shkzg = 'H'.
                dwn_py2 = dwn_py2 + i_ekbe-dmbtr.
              ENDIF.
              dwnpy = dwn_py1 - dwn_py2.
              itab-dwn_py = dwnpy.
            ENDIF.
          ENDLOOP.
* COMPARE NET PO VALUE WITH GOODS RECEIPT.
          IF totvl LT totnetvl.
            SELECT SINGLE * FROM lfa1 WHERE lifnr = i_ekko-lifnr.
            SELECT SINGLE * FROM ekkn WHERE ebeln = i_ekpo-ebeln.
            itab-bedat = i_ekko-bedat.
            itab-ebeln = i_ekko-ebeln.
            itab-lifnr = i_ekko-lifnr.
            itab-ven_name = lfa1-name1.
            itab-gsber = ekkn-gsber.
            itab-ekorg = i_ekko-ekorg.
            itab-ekgrp = i_ekko-ekgrp.
            itab-waers = i_ekko-waers.
            itab-wkurs = i_ekko-wkurs.
            itab-rlwrt = i_ekko-rlwrt.
            itab-ebelp = i_eket-ebelp.
            itab-matnr = i_ekpo-matnr.
            itab-werks = i_ekpo-werks.
            itab-grsval = totgrsvl. " GROSS PO VALUE
* FOR SERVICE PO NET AMT WILL BE GROSS AMT AS
* NO TRANSPORTATION CHARGES
            val1 = totnetvl - totvl.
            val2 = totgrsvl - totvl.
            itab-netpen = val1.
            itab-grspen = val2.
            IF i_ekko-waers NE 'INR'.
              itab-netpen = i_ekko-wkurs * val1.
              itab-grspen = i_ekko-wkurs * val2.
            ENDIF.
            APPEND itab.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
    AT NEW ebeln.
      IF itab-ebeln NE ' ' OR itab-ebeln NE 0.
        MOVE itab TO itab2.
        APPEND itab2.
      ENDIF.
    ENDAT.
  ENDLOOP.
  SORT itab2 BY ebeln ebelp.
* LAYOUT - FOR COLORED COLUMNS
  gs_layout-coltab_fieldname = 'CELCOL'.
  PERFORM cell_contents.
  PERFORM build.
  PERFORM eventtab_build CHANGING gt_events.
  PERFORM comment USING gt_list_top_of_page.
  PERFORM call_alv.

AT LINE-SELECTION.
  SET PARAMETER ID 'BES' FIELD itab2-ebeln.
  CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build .
* Define DATA FIELD CATALOG - Explain Field Description to ALV
  DATA: fieldcat_in TYPE slis_fieldcat_alv.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'LIFNR'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Vendor No'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'WERKS'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Plant'.
  fieldcat_ln-outputlen = 6.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'EKORG'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Pur Org'.
  fieldcat_ln-outputlen = 6.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'EKGRP'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Pur Group'.
  fieldcat_ln-outputlen = 6.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'GSBER'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Business Area'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'VEN_NAME'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Vendor Name'.
  fieldcat_ln-outputlen = 20.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'EBELN'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'PO Number'.
  fieldcat_ln-hotspot = 'X'.
  fieldcat_ln-outputlen = 10.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'BEDAT'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-hotspot = ' '.
  fieldcat_ln-seltext_l = 'PO Date'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'WAERS'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-key = ' '. "SUBTOTAL KEY
  fieldcat_ln-seltext_l = 'PO Currency'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'NETVAL'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-seltext_l = 'Net PO Value in Rs'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'GRSVAL'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-key = ' '. "SUBTOTAL KEY
  fieldcat_ln-seltext_l = 'Gross PO Value in Rs'.
  APPEND fieldcat_ln TO gt_fieldcat.
  fieldcat_ln-fieldname = 'NETPEN'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-key = ' '.
  fieldcat_ln-seltext_l = 'Net Pending Amt'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'GRSPEN'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-key = ' '.
  fieldcat_ln-seltext_l = 'Gross Pending Amt'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'DWN_PY'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-key = ' '. "SUBTOTAL KEY
  fieldcat_ln-seltext_l = 'Advances/DP'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'UNDEL_QTY'.
  fieldcat_ln-tabname = 'ITAB2'.
  fieldcat_ln-no_out = ' '.
  fieldcat_ln-key = ' '.
  fieldcat_ln-seltext_l = 'Undelv. Qty'.
  APPEND fieldcat_ln TO gt_fieldcat.
* DATA SORTING AND SUBTOTAL
  DATA: gs_sort TYPE slis_sortinfo_alv.
  CLEAR gs_sort.
  gs_sort-fieldname = 'EBELN'.
* GS_SORT-SPOS = 1.
  gs_sort-up = 'X'.
* GS_SORT-SUBTOT = 'X'.
  APPEND gs_sort TO gt_sort.
  CLEAR gs_sort.
  gs_sort-fieldname = 'LIFNR'.
* GS_SORT-SPOS = 1.
  gs_sort-up = 'X'.
* GS_SORT-SUBTOT = 'X'.
  APPEND gs_sort TO gt_sort.
ENDFORM. "BUILD
*&--------------------------------------------------------------------*
*& Form CALL_ALV
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM call_alv.
* ABAP ALV Grid List Viewer
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
  i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
  i_callback_user_command = 'FRM_ALV_USER_COMMAND'
  i_structure_name = 'ITAB2'
  is_layout = gs_layout
  it_fieldcat = gt_fieldcat[]
  i_default = 'X'
  i_save = 'A'
  is_variant = gt_variant
* IT_EVENTS = GT_EVENTS[]
** IT_EVENT_EXIT =
* IS_PRINT = GS_PRINT
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
  TABLES
  t_outtab = itab2.
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2.
ENDFORM. "CALL_ALV
*&--------------------------------------------------------------------*
*& Form EVENTTAB_BUILD
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* HEADER FORM
FORM eventtab_build CHANGING lt_events TYPE slis_t_event.
  CONSTANTS:
  gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
  DATA: ls_event TYPE slis_alv_event.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = lt_events.
  READ TABLE lt_events WITH KEY name = slis_ev_top_of_page
  INTO ls_event.
  IF sy-subrc = 0.
    MOVE gc_formname_top_of_page TO ls_event-form.
    APPEND ls_event TO lt_events.
  ENDIF.
ENDFORM. "EVENTTAB_BUILD
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = gt_list_top_of_page.
  WRITE: sy-datum RIGHT-JUSTIFIED, 'Page No', sy-pagno
  RIGHT-JUSTIFIED.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form END_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM end_of_page.
  WRITE AT (sy-linsz) sy-pagno CENTERED.
ENDFORM. "END_OF_PAGE
*&--------------------------------------------------------------------*
*& Form frm_alv_user_command
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*---------------------------------------------------------------------*
FORM frm_alv_user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
  CASE ucomm.
    WHEN '&IC1'.
      IF selfield-tabname = 'ITAB2'.
        IF selfield-fieldname = 'EBELN'.
          READ TABLE itab2 INDEX selfield-tabindex.
          IF sy-subrc = 0.
            SET PARAMETER ID 'BES' FIELD itab2-ebeln.
            CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
          ENDIF.
        ENDIF.
      ENDIF.
  ENDCASE.
ENDFORM. "frm_alv_user_command
*&---------------------------------------------------------------------*
*& Form CELL_CONTENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*CODE FOR MAKING THE GRID CELL CONTENTS COLORED
FORM cell_contents .
  LOOP AT itab2.
    CLEAR celcol1.
    celcol1-fieldname = 'LIFNR'.
    celcol1-color-col = syprindex.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'WERKS'.
    celcol1-color-col = syprindex + 1.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'EKGRP'.
    celcol1-color-col = syprindex + 6.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'GSBER'.
    celcol1-color-col = syprindex + 2.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'VEN_NAME'.
    celcol1-color-col = syprindex + 3.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'EBELN'.
    celcol1-color-col = syprindex + 4.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'BEDAT'.
    celcol1-color-col = syprindex + 5.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'NETVAL'.
    celcol1-color-col = syprindex + 6.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'GRSVAL'.
    celcol1-color-col = syprindex + 2.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'DWN_PY'.
    celcol1-color-col = syprindex + 4.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'NETPEN'.
    celcol1-color-col = syprindex + 3.
    APPEND celcol1 TO itab2-celcol.
    celcol1-fieldname = 'GRSPEN'.
    celcol1-color-col = syprindex + 5.
    APPEND celcol1 TO itab2-celcol.
    MODIFY itab2.
  ENDLOOP.
ENDFORM. " CELL_CONTENTS
*&---------------------------------------------------------------------*
*& Form COMMENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_HEADING[] text
*----------------------------------------------------------------------*
FORM comment USING p_heading TYPE slis_t_listheader.
  DATA: hline TYPE slis_listheader,
  text(70) TYPE c,
  sep(20) TYPE c.
  CLEAR: hline, text.
  hline-typ = 'H'.
  WRITE: 'List of Open Purchase Orders' TO hline-info.
  APPEND hline TO p_heading.
ENDFORM. " COMMENT
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ 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 cannot 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.