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

Sales Discount Report



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



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Sep 13, 2008 6:53 pm    Post subject: Sales Discount Report Reply with quote

Code:
REPORT z_sales_discount.

TYPES: BEGIN OF s_all,
  vkorg TYPE vkorg,              "sales organization
  fkart TYPE fkart,              "billing type
  fkdat TYPE fkdat,              "billing date
b_vbeln TYPE vbeln_vf,           "billing document
  kunag TYPE kunag,              "sold-to party
  spart TYPE spart,              "division
  gsber TYPE gsber,              "business area
  bstnk TYPE bstnk,              "po munber
  aubel TYPE vbeln_va,           "sales document
  matnr TYPE matnr,              "material number
  kwert TYPE kwert,              "gross value
  kbetr TYPE kbetr,              "rate(condition amount or percentage)
  knumv TYPE knumv,              "number of document condition
  kposn TYPE kposn,              "condition item number
  kschl TYPE kscha,              "condition type
b_posnr TYPE posnr_vf,           "billing item
  waerk TYPE waerk,              "sd document currency
  kurrf TYPE kurrf,              "exchange rate_accntg
  name1 TYPE name1_gp,           "name 1
  kunnr TYPE name1,              "customer name 1
  arktx TYPE arktx,              "short text for sales order item
  fkimg TYPE fkimg,              "actual billed quantity
  vrkme TYPE vrkme,              "sales unit
  netwr TYPE netwr_fp,           "net value of the billing item in document currency
s_vbeln TYPE vbeln_va,           "sales document
  ra01_discount TYPE kbetr,      "ra01%discount
  ra01_dis_amt  TYPE kwert,      "ra01 discount amount
  ra00_discount TYPE kbetr,      "ra00%discount
  ra00_dis_amt  TYPE kwert,      "ra00 discount amount
s_kwmeng TYPE kwmeng,            "sales order total quantity
s_kwert  TYPE kwert,             "sales order total gross value
  END OF s_all.


TYPES: BEGIN OF s_konv,
  kwert TYPE kwert,              "gross value
  kbetr TYPE kbetr,              "rate(condition amount or percentage)
  knumv TYPE knumv,              "number of document condition
  kposn TYPE kposn,              "condition item number
  kschl TYPE kscha,              "condition type
  END OF s_konv.

TYPES: BEGIN OF s_kna1,
  name1 TYPE name1_gp,           "name 1
  kunnr TYPE name1,              "customer name 1
  kunag TYPE kunag,              "sold-to party
  END OF s_kna1.

TYPES: BEGIN OF s_vbap,
  kwmeng TYPE kwmeng,            "cumulative order quantity in sales units
  abgru  TYPE abgru_va,          "reason for rejection of quotations and sales orders
s_vbeln  TYPE vbeln_va,          "sales document
  END OF s_vbap.

TYPE-POOLS: slis.                      "ALV Declarations

TYPES: t_all TYPE STANDARD TABLE OF s_all,
       t_konv TYPE STANDARD TABLE OF s_konv,
       t_kna1 TYPE STANDARD TABLE OF s_kna1,
       t_vbap TYPE STANDARD TABLE OF s_vbap.

DATA: it_all TYPE t_all,
      it_konv TYPE t_konv,
      it_kna1 TYPE t_kna1,
      it_vbap TYPE t_vbap,
      it_total TYPE t_all,
      it_total_out TYPE t_all.

DATA: wa_all TYPE LINE OF t_all,
      wa_konv TYPE LINE OF t_konv,
      wa_kna1 TYPE LINE OF t_kna1,
      wa_vbap TYPE LINE OF t_vbap,
      wa_total TYPE LINE OF t_all,
      wa_total_out TYPE LINE OF t_all.

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      gd_repid     LIKE sy-repid.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.

SELECT-OPTIONS: x_vkorg FOR wa_all-vkorg,                                "sales organization
                x_fkart FOR wa_all-fkart MATCHCODE OBJECT h_tvfk,        "billing type
                x_fkdat FOR wa_all-fkdat,                                "billing date
                x_vbeln FOR wa_all-b_vbeln MATCHCODE OBJECT f4_vbrk,     "billing document
                x_kunag FOR wa_all-kunag MATCHCODE OBJECT debi.          "sold-to party
SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.

PARAMETERS x_check AS CHECKBOX.

SELECT-OPTIONS: x_spart FOR wa_all-spart,                                "division
                x_gsber FOR wa_all-gsber MATCHCODE OBJECT h_tgsb,        "business area
                x_matnr FOR wa_all-matnr,                                "material
                x_bstnk FOR wa_all-bstnk,                                "po munber
                x_aubel FOR wa_all-aubel.                                "sales document

SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
  PERFORM data_select.
  PERFORM data_processing.

END-OF-SELECTION.
  PERFORM data_display.

*&---------------------------------------------------------------------*
*&      Form  data_select
*&---------------------------------------------------------------------*
*       perform data selecting
*----------------------------------------------------------------------*
FORM data_select.
  PERFORM select_from_vbrk_vbrp_vbak.
  PERFORM select_from_konv.
  PERFORM select_from_kna1.
  PERFORM select_from_vbap.
ENDFORM.                    "data_select

*&---------------------------------------------------------------------*
*&      Form  data_processing
*&---------------------------------------------------------------------*
*       perform data processing
*----------------------------------------------------------------------*
FORM data_processing.
  PERFORM get_gross_dis_amt.
  PERFORM get_total_gross.
  PERFORM get_total.
ENDFORM.                    "data_processing

*&---------------------------------------------------------------------*
*&      Form  data_display
*&---------------------------------------------------------------------*
*       perform data displaying
*----------------------------------------------------------------------*
FORM data_display.
  IF x_check = 'X'.
    PERFORM build_fieldcatalog.
    PERFORM display_alv_report USING it_all.
  ELSE.
    PERFORM build_fieldcatalog.
    PERFORM display_alv_report USING it_total_out.
  ENDIF.
ENDFORM.                    "data_display

*&---------------------------------------------------------------------*
*&      Form  select_from_vbrk_vbrp_vbak
*&---------------------------------------------------------------------*
*       1~select data from table vbrk/vbrp/vbak into it_all.
*       2~when billing type is 's1',add negative to net value
*----------------------------------------------------------------------*
FORM select_from_vbrk_vbrp_vbak.
  SELECT vbrk~vkorg
         vbrk~fkart
         vbrk~fkdat
         vbrk~vbeln AS b_vbeln
         vbrk~kunag
         vbrp~spart
         vbrp~matnr
         vbrp~gsber
         vbrp~aubel
         vbak~bstnk
         vbrk~knumv
         vbrp~posnr AS b_posnr
         vbrk~waerk
         vbrk~kurrf
         vbrp~matnr
         vbrp~arktx
         vbrp~fkimg
         vbrp~vrkme
         vbrp~netwr

    INTO CORRESPONDING FIELDS OF TABLE it_all
    FROM vbrp
    JOIN vbak ON vbak~vbeln = vbrp~aubel
    JOIN vbrk ON vbrk~vbeln = vbrp~vbeln
    WHERE vbrk~vkorg IN x_vkorg
    AND   vbrk~vkorg NOT IN ('4802','4803')
    AND   vbrk~fkart IN x_fkart
    AND   vbrk~fkart NOT IN ('ZMF8','ZPF8')
    AND   vbrk~fkdat IN x_fkdat
    AND   vbrk~vbeln IN x_vbeln
    AND   vbrk~kunag IN x_kunag
    AND   vbrp~spart IN x_spart
    AND   vbrp~matnr IN x_matnr
    AND   vbrp~gsber IN x_gsber
    AND   vbrp~aubel IN x_aubel.

  SORT it_all BY b_vbeln kunag.

  IF sy-subrc <> 0.
    MESSAGE i001(zjenni_msg).
  ENDIF.

  LOOP AT it_all INTO wa_all.
    IF wa_all-fkart = 'S1'.
      wa_all-netwr = -1 * wa_all-netwr.
      MODIFY it_all FROM wa_all TRANSPORTING netwr.
    ENDIF.
  ENDLOOP.
  CLEAR wa_all.

ENDFORM.                    "select_from_vbrk_vbrp_vbak

*&---------------------------------------------------------------------*
*&      Form  select_from_konv
*&---------------------------------------------------------------------*
*       select data from table konv into it_konv
*----------------------------------------------------------------------*
FORM select_from_konv.

  IF it_all[] IS NOT INITIAL.

    SELECT kwert
           kbetr
           knumv
           kposn
           kschl
      FROM konv
      INTO CORRESPONDING FIELDS OF TABLE it_konv
      FOR ALL ENTRIES IN it_all
      WHERE knumv = it_all-knumv
      AND   kposn = it_all-b_posnr
      AND   kschl IN ('PR00','RA00','RA01').
  ENDIF.
  SORT it_konv BY knumv kposn.

  IF sy-subrc <> 0.
    MESSAGE i001(zjenni_msg).
  ENDIF.

ENDFORM.                    "select_from_konv

*&---------------------------------------------------------------------*
*&      Form  select_from_kna1
*&---------------------------------------------------------------------*
*       select data from table kna1 into it_all
*----------------------------------------------------------------------*
FORM select_from_kna1.
  IF it_all[] IS NOT INITIAL.

    SELECT name1
           kunnr
      FROM kna1
      INTO CORRESPONDING FIELDS OF TABLE it_kna1
      FOR ALL ENTRIES IN it_all
      WHERE kunnr = it_all-kunag.
  ENDIF.
  SORT it_kna1 BY kunnr.

  IF sy-subrc <> 0.
    MESSAGE i001(zjenni_msg).
  ENDIF.

  LOOP AT it_all INTO wa_all.
    READ TABLE it_kna1 INTO wa_kna1
    WITH KEY kunnr = wa_all-kunag BINARY SEARCH.
    wa_all-name1 = wa_kna1-name1.
    MODIFY it_all  FROM wa_all TRANSPORTING name1.
  ENDLOOP.
  CLEAR wa_all.

ENDFORM.                    "select_from_kna1

*&---------------------------------------------------------------------*
*&      Form  select_from_vbap
*&---------------------------------------------------------------------*
*       1~select data from table vbap
*       2~get sales order total quantity
*----------------------------------------------------------------------*
FORM select_from_vbap.
  DATA: it_temp TYPE t_vbap,
        wa_temp TYPE LINE OF t_vbap.

  IF it_all[] IS NOT INITIAL.
    SELECT kwmeng
           abgru
           posnr
           vbeln AS s_vbeln
      FROM vbap
      INTO CORRESPONDING FIELDS OF TABLE it_vbap
      FOR ALL ENTRIES IN it_all
      WHERE vbeln = it_all-aubel
      AND   posnr = it_all-b_posnr
      AND   abgru = ''.
  ENDIF.
  SORT it_vbap BY kwmeng.

  IF sy-subrc <> 0.
    MESSAGE i001(zjenni_msg).
  ENDIF.

  LOOP AT it_vbap INTO wa_vbap.
    COLLECT wa_vbap INTO it_temp.
  ENDLOOP.
  CLEAR wa_vbap.

  LOOP AT it_all INTO wa_all.
    READ TABLE it_temp INTO wa_temp
    WITH KEY s_vbeln = wa_all-aubel BINARY SEARCH.
    wa_all-s_kwmeng = wa_temp-kwmeng.
    MODIFY it_all  FROM wa_all TRANSPORTING s_kwmeng.
  ENDLOOP.
  CLEAR wa_all.

ENDFORM.                    "select_from_vbap

*&---------------------------------------------------------------------*
*&      Form  get_gross_dis_amt
*&---------------------------------------------------------------------*
*       get particular gross value, discount,discount amount
*----------------------------------------------------------------------*
FORM get_gross_dis_amt.
  DATA: it_temp TYPE t_konv,
        wa_temp TYPE LINE OF t_konv.

  LOOP AT it_all INTO wa_all.
    READ TABLE it_konv INTO wa_konv
    WITH KEY knumv = wa_all-knumv
             kposn = wa_all-b_posnr
             BINARY SEARCH.

    IF wa_konv-kschl = 'PR00'.
      wa_all-kwert = wa_konv-kwert.
      MODIFY it_all FROM wa_all TRANSPORTING kwert.
    ENDIF.

    IF wa_konv-kschl = 'RA01'.
      wa_all-ra01_discount = wa_konv-kbetr / 10.
      wa_all-ra01_dis_amt = wa_konv-kwert.
      MODIFY it_all FROM wa_all TRANSPORTING ra01_discount.
      MODIFY it_all FROM wa_all TRANSPORTING ra01_dis_amt.
    ENDIF.

    IF wa_konv-kschl = 'RA00'.
      wa_all-ra01_discount = wa_konv-kbetr / 10.
      wa_all-ra01_dis_amt = wa_konv-kwert.
      MODIFY it_all FROM wa_all TRANSPORTING ra00_discount.
      MODIFY it_all FROM wa_all TRANSPORTING ra00_dis_amt.
    ENDIF.
    CLEAR wa_konv.

  ENDLOOP.
  CLEAR wa_all.

ENDFORM.                    "get_gross_dis_amt

*&---------------------------------------------------------------------*
*&      Form  get_total_gross
*&---------------------------------------------------------------------*
*       1~get total gross value
*       2~when billing type is 's1',add negative to gross value and total gross
*----------------------------------------------------------------------*
FORM get_total_gross.
  DATA: it_temp TYPE t_konv,
        wa_temp TYPE LINE OF t_konv,
        it_konv_temp TYPE t_konv,
        wa_konv_temp TYPE LINE OF t_konv.

  IF it_all[] IS NOT INITIAL.
    SELECT kwert
           knumv
           kschl
      FROM konv
      INTO CORRESPONDING FIELDS OF TABLE it_konv_temp
      FOR ALL ENTRIES IN it_all
      WHERE knumv = it_all-knumv
      AND   kschl = 'PR00'.
  ENDIF.

  LOOP AT it_konv_temp INTO wa_konv_temp.
    COLLECT wa_konv_temp INTO it_temp.
  ENDLOOP.
  CLEAR wa_konv_temp.

  LOOP AT it_temp INTO wa_temp.
*    write: at / wa_temp-kwert,
*                '@'.
  ENDLOOP.

  LOOP AT it_all INTO wa_all.
    READ TABLE it_temp INTO wa_temp
    WITH KEY knumv = wa_all-knumv
    BINARY SEARCH.
    wa_all-s_kwert = wa_temp-kwert.
    MODIFY it_all  FROM wa_all TRANSPORTING s_kwert.
  ENDLOOP.
  CLEAR wa_all.

  LOOP AT it_all INTO wa_all.
    IF wa_all-fkart = 'S1'.
      wa_all-kwert = -1 * wa_all-kwert.
      wa_all-s_kwert = -1 * wa_all-s_kwert.
      MODIFY it_all FROM wa_all TRANSPORTING kwert s_kwert.
    ENDIF.
  ENDLOOP.
  CLEAR wa_all.

ENDFORM.                    "get_total_gross

*&---------------------------------------------------------------------*
*&      Form  get_total
*&---------------------------------------------------------------------*
*       get all the total value into it_total_out
*----------------------------------------------------------------------*
FORM get_total.
  DATA: it_total_temp TYPE t_all,
        wa_total_temp TYPE LINE OF t_all.

  LOOP AT it_all INTO wa_all.
    wa_total_temp-b_vbeln = wa_all-b_vbeln.
    wa_total_temp-fkart = wa_all-fkart.
    wa_total_temp-vkorg = wa_all-vkorg.
    wa_total_temp-kunag = wa_all-kunag.
    wa_total_temp-name1 = wa_all-name1.
    wa_total_temp-fkdat = wa_all-fkdat.
    wa_total_temp-fkimg = wa_all-fkimg.
    wa_total_temp-ra01_discount = wa_all-ra01_discount.
    wa_total_temp-ra00_discount = wa_all-ra00_discount.
    wa_total_temp-netwr = wa_all-netwr.
    wa_total_temp-vrkme = wa_all-vrkme.
    wa_total_temp-waerk = wa_all-waerk.
    APPEND wa_total_temp TO it_total.
  ENDLOOP.
  CLEAR wa_all.

  LOOP AT it_total INTO wa_total.
    COLLECT wa_total INTO it_total_out.
  ENDLOOP.
  CLEAR wa_total.

  LOOP AT it_total_out INTO wa_total_out.
    READ TABLE it_all INTO wa_all
    WITH KEY b_vbeln = wa_total_out-b_vbeln BINARY SEARCH.
    wa_total_out-kurrf = wa_all-kurrf.
    wa_total_out-kwert = wa_all-s_kwert.
    MODIFY it_total_out FROM wa_total_out TRANSPORTING kurrf kwert netwr.
  ENDLOOP.
  CLEAR wa_total_out.

ENDFORM.                    "get_total

*&---------------------------------------------------------------------*
*&      Form  build_fieldcatalog
*&---------------------------------------------------------------------*
*       form fieldcatalog for both items and totals
*----------------------------------------------------------------------*
FORM build_fieldcatalog.

  DATA count TYPE i VALUE 1.

  fieldcatalog-fieldname   = 'B_VBELN'.
  fieldcatalog-seltext_l   = 'Billing Document'(001).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'FKART'.
  fieldcatalog-seltext_l   = 'Billing Type'(003).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'VKORG'.
  fieldcatalog-seltext_l   = 'Sales Org'(002).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'KUNAG'.
  fieldcatalog-seltext_l   = 'Sold-to Party'(005).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'NAME1'.
  fieldcatalog-seltext_l   = 'Name'(011).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'FKDAT'.
  fieldcatalog-seltext_l   = 'Billing date'(004).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'SPART'.
  fieldcatalog-seltext_l   = 'Division'(006).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'MATNR'.
  fieldcatalog-seltext_l   = 'Material No'(008).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'ARKTX'.
  fieldcatalog-seltext_l   = 'Material Description'(012).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'FKIMG'.
  fieldcatalog-seltext_l   = 'Billing Qty'(013).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'VRKME'.
  fieldcatalog-seltext_l   = 'Sales Unit'(014).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'KURRF'.
  fieldcatalog-seltext_l   = 'Exchange rate-accntg'(015).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'KWERT'.
  fieldcatalog-seltext_l   = 'Gross Value'(016).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'WAERK'.
  fieldcatalog-seltext_l   = 'Currency'(017).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'RA01_DISCOUNT'.
  fieldcatalog-seltext_l   = 'RA01%Discount'(018).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = ''.
  fieldcatalog-seltext_l   = ''.
  fieldcatalog-edit_mask   = '%'.
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'RA01_DIS_AMT'.
  fieldcatalog-seltext_l   = 'RA01 Discount Amount'(019).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'WAERK'.
  fieldcatalog-seltext_l   = 'Currency'(017).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   =  'RA00_DISCOUNT'.
  fieldcatalog-seltext_l   =  'RA00%Discount'(020).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = ''.
  fieldcatalog-seltext_l   = ''.
  fieldcatalog-edit_mask   = '%'.
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'RA00_DIS_AMT'.
  fieldcatalog-seltext_l   = 'RA00 Discount Amount'(021).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   =  'WAERK'.
  fieldcatalog-seltext_l   =  'Currency'(017).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'NETWR'.
  fieldcatalog-seltext_l   = 'Net Value'(022).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   =  'WAERK'.
  fieldcatalog-seltext_l   =  'Currency'(017).
  fieldcatalog-col_pos     = count.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  count = count + 1.

  fieldcatalog-fieldname   = 'GSBER'.
  fieldcatalog-seltext_l   = 'Business Area'(007).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'BSTNK'.
  fieldcatalog-seltext_l   = 'PO Number'(009).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'AUBEL'.
  fieldcatalog-seltext_l   = 'Sales Document'(010).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   =  'S_KWMENG'.
  fieldcatalog-seltext_l   =  'Sales Order Total Quantity'(023).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   = 'S_KWERT'.
  fieldcatalog-seltext_l   = 'Sales Order Total Gross Value'(024).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

  fieldcatalog-fieldname   =  'WAERK'.
  fieldcatalog-seltext_l   =  'Currency'(017).
  fieldcatalog-col_pos     = count.
  IF x_check <> 'X'.
    fieldcatalog-no_out      =  'X'.
    count = count + 1.
  ENDIF.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

ENDFORM.                    " BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*
*&      Form  display_alv_report
*&---------------------------------------------------------------------*
*       form alv display
*----------------------------------------------------------------------*
*      -->FT_OUTPUT  text
*----------------------------------------------------------------------*
FORM display_alv_report USING ft_output TYPE STANDARD TABLE.
  gd_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = gd_repid
      it_fieldcat        = fieldcatalog[]
      i_save             = 'X'
    TABLES
      t_outtab           = ft_output
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " DISPLAY_ALV_REPORT
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 -> SD 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.