Friday 29 January 2021

Use the new open SQL to get company, account, and monthly gains and losses and balances from ACDOCA.

Introduction

From SAP ERP 6.0 to SAP S / 4, the standard table structure has changed significantly.

I mainly understand it as a change to accommodate reporting.

On the other hand, I feel that there are a minority of developers who can imagine the concrete source code of CodePushdown.

This time, we will introduce a sample program that outputs a monthly increase / decrease amount and balance as a report.

This sample program is created by accessing the ACDOCA of the SAP standard table and using the Code Pushdown design method.

The sample program uses New open SQL.

It is easy to implement a similar design with the following technologies.

・ ABAP CDS view

・ HANA infomation view

・ Composite Provider (SAP BW)

I hope it will help you to imagine the concrete source code of Code Pushdown promoted by SAP.

Subject

The basic idea is to acquire data using ACDOCA as a FactTable.

In preparation, use ITAB to create a DecisionTable to get the balance.

Use the With clause of New open SQL to do three main things.

・ First process

Filters data by selection criteria.

Aggregate on a monthly basis for ACDOCA.

・ Second process

In the first half, you get the increase / decrease value. Use the SQL aggregate function SUM ().

In the second half, you will get the balance. Join ACDOCA and Decision Table with Inner Join.

The record is amplified to get the cumulative amount (balance).

・ Third process

The increase / decrease amount and balance are output as side-by-side items.

Get text information from G / L account master table.

The execution environment is ABAP 7.52 or later.

The SQL instructions to use are as follows.

・ With

・ Select ~ from @itab

・ Inner join

・ Sum () ~ group by

・ Union all

Conclusion

-I think I was able to show a concrete coding example of Code Pushdown.

-The processing speed was ACDOCA: 3 million records, and the response time was 0.1 sec or less.

-Compared to Non-Code Pushdown, the amount of coding is reduced.

-You can expect the effect of suppressing program bugs.

-By introducing the Code Pushdown design method, the following can be achieved.

・ Real Time Repoting

・ Low Cost Development

・ Low Cost Operation

・ Low Cost Maintenance

Supplement

If ITAB cannot be used, a real table will be used instead.

・ ABAP CDS: Add-on Table

- Composite Provider (SAP BW): InfoObject Master Table

You can get a monthly list of all account codes at once by switching the increase / decrease amount and balance using the CASE clause according to the PL account and BS account from the account code master.

The source code is as follows.

*&---------------------------------------------------------------------*

*& Report Y_SQL_CONSOLE

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT Y_SQL_CONSOLE.

*-----------------------------------------------------------------------

* GLOBAL VARIABLE

*-----------------------------------------------------------------------

DATA GDF_SUBRC TYPE SY-SUBRC.

*-----------------------------------------------------------------------

* CONDITION VIEW

*-----------------------------------------------------------------------

DATA GDF_RLDNR TYPE ACDOCA-RLDNR.

TYPES GTR_RLDNR LIKE RANGE OF GDF_RLDNR.

SELECT-OPTIONS S_RLDNR FOR GDF_RLDNR DEFAULT '0L'."Ledger in General Ledger Accounting,

DATA GDF_RBUKRS TYPE ACDOCA-RBUKRS.

TYPES GTR_RBUKRS LIKE RANGE OF GDF_RBUKRS.

SELECT-OPTIONS S_RBUKRS FOR GDF_RBUKRS.           "Company Code

DATA GDF_RACCT TYPE ACDOCA-RACCT.

TYPES GTR_RACCT LIKE RANGE OF GDF_RACCT.

SELECT-OPTIONS S_RACCT FOR GDF_RACCT.             "Account Number

*-----------------------------------------------------------------------

* START-OF-SELECTION

*-----------------------------------------------------------------------

START-OF-SELECTION.

  PERFORM START_OF_SELECTION

    USING

      S_RLDNR[]

      S_RBUKRS[]

      S_RACCT[]

    CHANGING

      GDF_SUBRC.

*-----------------------------------------------------------------------

* SUBROUTINE

*-----------------------------------------------------------------------

FORM START_OF_SELECTION

    USING

      PIR_RLDNR TYPE GTR_RLDNR

      PIR_RBUKRS TYPE GTR_RBUKRS

      PIR_RACCT TYPE GTR_RACCT

    CHANGING

      POF_SUBRC TYPE SY-SUBRC.

*-----------------------------------------------------------------------

* Please write the SQL statement here ☆

* Set the internal table to be stored to LDT_DATA ☆

* Inline definition of LDT_DATA is fun ☆

  SELECT

    FROM ACDOCA

    FIELDS COUNT( * ) AS LDF_INPUT_RECORDS

    WHERE ACDOCA~RLDNR  IN @PIR_RLDNR             "Ledger in General Ledger Accounting,

      AND ACDOCA~RBUKRS IN @PIR_RBUKRS            "Company Code

      AND ACDOCA~RACCT  IN @PIR_RACCT             "Account Number

    INTO @DATA(LDF_INPUT_RECORDS).

  DATA LDF_TIMESTAMP_START TYPE TIMESTAMPL.

  GET TIME STAMP FIELD LDF_TIMESTAMP_START.

  "In preparation, use ITAB to create a DecisionTable to get the balance.

  TYPES:

    BEGIN OF LTS_DECISION,

      COEFFICIENT  TYPE FINS_VHCUR12,

      POPER_SOURCE TYPE ACDOCA-POPER,

      POPER_TARGET TYPE ACDOCA-POPER,

    END OF LTS_DECISION,

    LTT_DECISION TYPE STANDARD TABLE OF LTS_DECISION.

  DATA LDT_DECISION TYPE LTT_DECISION.

  LDT_DECISION = VALUE #(

        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '001' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '001' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '002' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '002' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '002' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '003' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '003' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '003' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '003' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '004' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '004' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '004' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '004' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '004' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '005' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '005' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '005' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '005' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '005' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '005' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '006' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '006' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '006' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '006' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '006' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '006' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '006' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '007' )

        ( COEFFICIENT = 1 POPER_SOURCE = '007' POPER_TARGET = '007' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '007' POPER_TARGET = '008' )

        ( COEFFICIENT = 1 POPER_SOURCE = '008' POPER_TARGET = '008' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '007' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '008' POPER_TARGET = '009' )

        ( COEFFICIENT = 1 POPER_SOURCE = '009' POPER_TARGET = '009' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '007' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '008' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '009' POPER_TARGET = '010' )

        ( COEFFICIENT = 1 POPER_SOURCE = '010' POPER_TARGET = '010' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '007' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '008' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '009' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '010' POPER_TARGET = '011' )

        ( COEFFICIENT = 1 POPER_SOURCE = '011' POPER_TARGET = '011' )


        ( COEFFICIENT = 1 POPER_SOURCE = '000' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '001' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '002' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '003' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '004' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '005' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '006' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '007' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '008' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '009' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '010' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '011' POPER_TARGET = '012' )

        ( COEFFICIENT = 1 POPER_SOURCE = '012' POPER_TARGET = '012' ) ).


  WITH

  "・ First process

  "Filters data by selection criteria.

  "Aggregate on a monthly basis for ACDOCA.

  +ACDOCA AS ( SELECT

    FROM ACDOCA

    FIELDS

      ACDOCA~RLDNR,                               "Ledger in General Ledger Accounting

      ACDOCA~RBUKRS,                              "Company Code

      ACDOCA~PERIV,                               "Fiscal Year Variant

      ACDOCA~GJAHR,                               "Fiscal Year

      ACDOCA~POPER,                               "Posting period

      ACDOCA~KTOPL,                               "Chart of Accounts

      ACDOCA~RACCT,                               "Account Number

      ACDOCA~RCNTR,                               "Cost Center

      ACDOCA~PRCTR,                               "Profit Center

      ACDOCA~RFAREA,                              "Functional Area

      ACDOCA~RBUSA,                               "Business Area

      ACDOCA~KOKRS,                               "Controlling Area

      ACDOCA~WERKS,                               "Plant

      ACDOCA~MATNR,                               "Material Number

      ACDOCA~LIFNR,                               "Account Number of Vendor or Creditor

      ACDOCA~KUNNR,                               "Customer Number

      ACDOCA~RWCUR,                               "Transaction Currency

      ACDOCA~RHCUR,                               "Company Code Currency

      SUM( ACDOCA~WSL ) AS WSL,                   "Amount in Transaction Currency

      SUM( ACDOCA~HSL ) AS HSL                    "Amount in Company Code Currency

    WHERE ACDOCA~RBUKRS IN @PIR_RBUKRS            "Company Code

      AND ACDOCA~RACCT  IN @PIR_RACCT             "Account Number

    GROUP BY

      ACDOCA~RLDNR,                               "Ledger in General Ledger Acc

      ACDOCA~RBUKRS,                              "Company Code

      ACDOCA~PERIV,                               "Fiscal Year Variant

      ACDOCA~GJAHR,                               "Fiscal Year

      ACDOCA~POPER,                               "Posting period

      ACDOCA~KTOPL,                               "Chart of Accounts

      ACDOCA~RACCT,                               "Account Number

      ACDOCA~RCNTR,                               "Cost Center

      ACDOCA~PRCTR,                               "Profit Center

      ACDOCA~RFAREA,                              "Functional Area

      ACDOCA~RBUSA,                               "Business Area

      ACDOCA~KOKRS,                               "Controlling Area

      ACDOCA~WERKS,                               "Plant

      ACDOCA~MATNR,                               "Material Number

      ACDOCA~LIFNR,                               "Account Number of Vendor or

      ACDOCA~KUNNR,                               "Customer Number

      ACDOCA~RWCUR,                               "Transaction Currency

      ACDOCA~RHCUR ),                             "Company Code Currency

  "・ Second process

  +ACDOCA01 AS (

  "In the first half, you get the increase / decrease value. Use the SQL aggregate function SUM ().

  SELECT

    FROM +ACDOCA

    FIELDS

      +ACDOCA~RLDNR,                              "Ledger in General Ledger Accounting

      +ACDOCA~RBUKRS,                             "Company Code

      +ACDOCA~PERIV,                              "Fiscal Year Variant

      +ACDOCA~GJAHR,                              "Fiscal Year

      +ACDOCA~POPER,                              "Posting period

      +ACDOCA~KTOPL,                              "Chart of Accounts

      +ACDOCA~RACCT,                              "Account Number

      +ACDOCA~RCNTR,                              "Cost Center

      +ACDOCA~PRCTR,                              "Profit Center

      +ACDOCA~RFAREA,                             "Functional Area

      +ACDOCA~RBUSA,                              "Business Area

      +ACDOCA~KOKRS,                              "Controlling Area

      +ACDOCA~WERKS,                              "Plant

      +ACDOCA~MATNR,                              "Material Number

      +ACDOCA~LIFNR,                              "Account Number of Vendor or Creditor

      +ACDOCA~KUNNR,                              "Customer Number

      +ACDOCA~RWCUR,                              "Transaction Currency

      +ACDOCA~RHCUR,                              "Company Code Currency

      +ACDOCA~WSL AS WSL00,                       "Amount in Transaction Currency

      +ACDOCA~HSL AS HSL00,                       "Amount in Company Code Currency

      CAST( 0 AS DEC( 23, 2 ) ) AS WSL01,         "Amount in Transaction Currency

      CAST( 0 AS DEC( 23, 2 ) ) AS HSL01          "Amount in Company Code Currency

  "In the second half, you will get the balance. Join ACDOCA and Decision Table with Inner Join.

  "The record is amplified to get the cumulative amount (balance).

  UNION ALL SELECT

    FROM +ACDOCA

    INNER JOIN @LDT_DECISION AS LDT_DECISION

      ON LDT_DECISION~POPER_SOURCE = +ACDOCA~POPER

    FIELDS

      +ACDOCA~RLDNR,                              "Ledger in General Ledger Accounting

      +ACDOCA~RBUKRS,                             "Company Code

      +ACDOCA~PERIV,                              "Fiscal Year Variant

      +ACDOCA~GJAHR,                              "Fiscal Year

      LDT_DECISION~POPER_TARGET AS POPER,         "Posting period

      +ACDOCA~KTOPL,                              "Chart of Accounts

      +ACDOCA~RACCT,                              "Account Number

      +ACDOCA~RCNTR,                              "Cost Center

      +ACDOCA~PRCTR,                              "Profit Center

      +ACDOCA~RFAREA,                             "Functional Area

      +ACDOCA~RBUSA,                              "Business Area

      +ACDOCA~KOKRS,                              "Controlling Area

      +ACDOCA~WERKS,                              "Plant

      +ACDOCA~MATNR,                              "Material Number

      +ACDOCA~LIFNR,                              "Account Number of Vendor or Creditor

      +ACDOCA~KUNNR,                              "Customer Number

      +ACDOCA~RWCUR,                              "Transaction Currency

      +ACDOCA~RHCUR,                              "Company Code Currency

      CAST( 0 AS DEC( 23, 2 ) ) AS WSL00,         "Amount in Transaction Currency

      CAST( 0 AS DEC( 23, 2 ) ) AS HSL00,         "Amount in Company Code Currency

      SUM( +ACDOCA~WSL ) AS WSL01,                "Amount in Transaction Currency

      SUM( +ACDOCA~HSL ) AS HSL01                 "Amount in Company Code Currency

    GROUP BY

      +ACDOCA~RLDNR,                              "Ledger in General Ledger Accounting

      +ACDOCA~RBUKRS,                             "Company Code

      +ACDOCA~PERIV,                              "Fiscal Year Variant

      +ACDOCA~GJAHR,                              "Fiscal Year

      LDT_DECISION~POPER_TARGET,                  "Posting period

      +ACDOCA~KTOPL,                              "Chart of Accounts

      +ACDOCA~RACCT,                              "Account Number

      +ACDOCA~RCNTR,                              "Cost Center

      +ACDOCA~PRCTR,                              "Profit Center

      +ACDOCA~RFAREA,                             "Functional Area

      +ACDOCA~RBUSA,                              "Business Area

      +ACDOCA~KOKRS,                              "Controlling Area

      +ACDOCA~WERKS,                              "Plant

      +ACDOCA~MATNR,                              "Material Number

      +ACDOCA~LIFNR,                              "Account Number of Vendor or Creditor

      +ACDOCA~KUNNR,                              "Customer Number

      +ACDOCA~RWCUR,                              "Transaction Currency

      +ACDOCA~RHCUR )                             "Company Code Currency

  "・ Third process

  "The increase / decrease amount and balance are output as side-by-side items.

  "Get text information from G / L account master table.

  SELECT

    FROM +ACDOCA01

    INNER JOIN SKA1

       ON SKA1~KTOPL = +ACDOCA01~KTOPL

      AND SKA1~SAKNR = +ACDOCA01~RACCT

      AND SKA1~XBILK = @ABAP_TRUE

    LEFT OUTER JOIN SKAT

       ON SKAT~SPRAS = @SY-LANGU

      AND SKAT~KTOPL = SKA1~KTOPL

      AND SKAT~SAKNR = SKA1~SAKNR

    FIELDS

      +ACDOCA01~RLDNR,                            "Ledger in General Ledger Accounting

      +ACDOCA01~RBUKRS,                           "Company Code

      +ACDOCA01~PERIV,                            "Fiscal Year Variant

      +ACDOCA01~GJAHR,                            "Fiscal Year

      +ACDOCA01~POPER,                            "Posting period

      +ACDOCA01~KTOPL,                            "Chart of Accounts

      +ACDOCA01~RACCT,                            "Account Number

      SKAT~TXT20,                                 "G/L account short text

      +ACDOCA01~RCNTR,                            "Cost Center

      +ACDOCA01~PRCTR,                            "Profit Center

      +ACDOCA01~RFAREA,                           "Functional Area

      +ACDOCA01~RBUSA,                            "Business Area

      +ACDOCA01~KOKRS,                            "Controlling Area

      +ACDOCA01~WERKS,                            "Plant

      +ACDOCA01~MATNR,                            "Material Number

      +ACDOCA01~LIFNR,                            "Account Number of Vendor or Creditor

      +ACDOCA01~KUNNR,                            "Customer Number

      +ACDOCA01~RWCUR,                            "Transaction Currency

      +ACDOCA01~RHCUR,                            "Company Code Currency

      SUM( +ACDOCA01~WSL00 ) AS WSL00,            "Amount in Transaction Currency

      SUM( +ACDOCA01~HSL00 ) AS HSL00,            "Amount in Company Code Currency

      SUM( +ACDOCA01~WSL01 ) AS WSL01,            "Amount in Transaction Currency

      SUM( +ACDOCA01~HSL01 ) AS HSL01             "Amount in Company Code Currency

    GROUP BY

      +ACDOCA01~RLDNR,                            "Ledger in General Ledger Accounting

      +ACDOCA01~RBUKRS,                           "Company Code

      +ACDOCA01~PERIV,                            "Fiscal Year Variant

      +ACDOCA01~GJAHR,                            "Fiscal Year

      +ACDOCA01~POPER,                            "Posting period

      +ACDOCA01~KTOPL,                            "Chart of Accounts

      +ACDOCA01~RACCT,                            "Account Number

      SKAT~TXT20,                                 "G/L account short text

      +ACDOCA01~RCNTR,                            "Cost Center

      +ACDOCA01~PRCTR,                            "Profit Center

      +ACDOCA01~RFAREA,                           "Functional Area

      +ACDOCA01~RBUSA,                            "Business Area

      +ACDOCA01~KOKRS,                            "Controlling Area

      +ACDOCA01~WERKS,                            "Plant

      +ACDOCA01~MATNR,                            "Material Number

      +ACDOCA01~LIFNR,                            "Account Number of Vendor or Creditor

      +ACDOCA01~KUNNR,                            "Customer Number

      +ACDOCA01~RWCUR,                            "Transaction Currency

      +ACDOCA01~RHCUR                             "Company Code Currency

    ORDER BY

      +ACDOCA01~RLDNR,                            "Ledger in General Ledger Accounting

      +ACDOCA01~RBUKRS,                           "Company Code

      +ACDOCA01~KTOPL,                            "Fiscal Year Variant

      +ACDOCA01~RACCT,                            "Fiscal Year

      SKAT~TXT20,                                 "Posting period

      +ACDOCA01~RCNTR,                            "Chart of Accounts

      +ACDOCA01~PRCTR,                            "Account Number

      +ACDOCA01~RFAREA,                           "G/L account short text

      +ACDOCA01~RBUSA,                            "Cost Center

      +ACDOCA01~KOKRS,                            "Profit Center

      +ACDOCA01~WERKS,                            "Functional Area

      +ACDOCA01~MATNR,                            "Business Area

      +ACDOCA01~LIFNR,                            "Controlling Area

      +ACDOCA01~KUNNR,                            "Plant

      +ACDOCA01~RWCUR,                            "Material Number

      +ACDOCA01~PERIV,                            "Account Number of Vendor or Creditor

      +ACDOCA01~GJAHR,                            "Customer Number

      +ACDOCA01~POPER,                            "Transaction Currency

      +ACDOCA01~RHCUR                             "Company Code Currency

    INTO TABLE @DATA(LDT_DATA).

  DATA LDF_TIMESTAMP_END TYPE TIMESTAMPL.

  GET TIME STAMP FIELD LDF_TIMESTAMP_END.

*-----------------------------------------------------------------------

  TRY.

      CL_SALV_TABLE=>FACTORY(

        IMPORTING

          R_SALV_TABLE = DATA(LDO_ALV)

        CHANGING

          T_TABLE  = LDT_DATA ).

    CATCH CX_SALV_MSG INTO DATA(LDX_SALV_MSG).

      POF_SUBRC = 8.

      RETURN.

  ENDTRY.

  DATA(LDO_HEADER) = NEW CL_SALV_FORM_LAYOUT_GRID( ).

  DATA(LDO_H_LABEL) = LDO_HEADER->CREATE_LABEL( ROW = 1 COLUMN = 1 ).

  LDO_H_LABEL->SET_TEXT( 'Performance data' ).


  DATA(LDO_H_FLOW) = LDO_HEADER->CREATE_FLOW( ROW = 2  COLUMN = 1 ).

  LDO_H_FLOW->CREATE_TEXT( TEXT = 'Input records' ).

  LDO_H_FLOW = LDO_HEADER->CREATE_FLOW( ROW = 2  COLUMN = 2 ).

  LDO_H_FLOW->CREATE_TEXT( TEXT = LDF_INPUT_RECORDS ).


  LDO_H_FLOW = LDO_HEADER->CREATE_FLOW( ROW = 3  COLUMN = 1 ).

  LDO_H_FLOW->CREATE_TEXT( TEXT = 'Output records' ).

  LDO_H_FLOW = LDO_HEADER->CREATE_FLOW( ROW = 3  COLUMN = 2 ).

  LDO_H_FLOW->CREATE_TEXT( TEXT = LINES( LDT_DATA ) ).


  LDO_H_FLOW = LDO_HEADER->CREATE_FLOW( ROW = 4  COLUMN = 1 ).

  LDO_H_FLOW->CREATE_TEXT( TEXT = 'Timestamp of start' ).

  LDO_H_FLOW = LDO_HEADER->CREATE_FLOW( ROW = 4  COLUMN = 2 ).

  LDO_H_FLOW->CREATE_TEXT( TEXT = CL_ABAP_TSTMP=>SUBTRACT( EXPORTING TSTMP1 = LDF_TIMESTAMP_END TSTMP2 = LDF_TIMESTAMP_START ) ).

  LDO_ALV->SET_TOP_OF_LIST( LDO_HEADER ).

  LDO_ALV->SET_TOP_OF_LIST_PRINT( LDO_HEADER ).

  LDO_ALV->GET_FUNCTIONS( )->SET_ALL( ).

  LDO_ALV->GET_COLUMNS( )->SET_OPTIMIZE( ).

  LDO_ALV->GET_SELECTIONS( )->SET_SELECTION_MODE( EXPORTING VALUE = IF_SALV_C_SELECTION_MODE=>CELL ).

  LDO_ALV->DISPLAY( ).

  POF_SUBRC = 0.

ENDFORM.

No comments:

Post a Comment