cancel
Showing results for 
Search instead for 
Did you mean: 

VA05-> Enhancement LOG_SD_REPORT_OPT business function SD for optimized reports. Fails

0 Kudos
1,530

Hello experts,

we are certainly not the only ones who have activated this beautiful enhancement...

I have activated the enhancement for the optimized reports (LOG_SD_REPORT_OPT; transaction SFW5) and now want to import additional data into the result list.

I used the OSS note "1780163 - Report optimization: Access to further tables" as a guide.

Now I would like to read the country of the goods receiver (VBPA-LAND1) . For this I created the method ADAPT_RESULT_COMP from the interface IF_BADI_SDOC_WRAPPER

Based on the coding in the example, it looks like this:

  REFRESH lt_join_metadata.
    INSERT VALUE #( table        = 'VBPA'
                    field        = 'LAND1'
                    "table_alias  = 'Z_VBPA_WE'
                    name         = 'ZLAND1' ) INTO TABLE ct_result_comp.

    INSERT VALUE #( target_field = 'VBELN'
                    source_table = 'VBAK'
                    source_field = 'VBELN' ) INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_field   = 'POSNR'
                    constant_value = '000000' ) INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_field   = 'PARVW'
                    constant_value = 'WE' ) INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_table  = 'VBPA'
                    "table_alias   = 'Z_VBPA_WE'
                    join_metadata = lt_join_metadata ) INTO TABLE ct_additional_table_metadata.

...the field ZLAND1 remains empty.

Next time i used alias tables ( Z_VBPA_WE ). But then i get a runtime error:

Category               ABAP programming error
Runtime Errors         UNCAUGHT_EXCEPTION
Except.                CX_SDOC_REPORTING
ABAP Program           CL_SDOC_SELECT_BASIC==========CP
Application Component  SD-SLS-GF
Date and Time          01.09.2022 15:47:18
SQL_CODE                       8010-
SQL_MESSAGE                    POS(297) Table name must be in from list:Z_VBPA_WE<br>

Another example that basically does the same thing works fine. The field TEST is filled with the desribtion.

INSERT VALUE #( table        = 'TVAUT' "Sales Documents: Order Reasons: Texts
                    field        = 'BEZEI'
                    table_alias  = 'ALIAS_TVAUT'
                    name         = 'TEST' ) INTO TABLE ct_result_comp.

    " Join TVAUT VBAK
    INSERT VALUE #( target_field = 'AUGRU'
                    source_table = 'VBAK'
                    source_field = 'AUGRU' ) INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_field = 'SPRAS'
                    constant_value = sy-langu ) INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_table  = 'TVAUT'
                    table_alias   = 'ALIAS_TVAUT'
                    join_metadata = lt_join_metadata ) INTO TABLE ct_additional_table_metadata.

It probably has something to do with the fact that in the first case the table VBPA is searched for and this already exists in the standard process?

Has anyone managed to add the partner data yet?

Greetings

View Entire Topic
sapdev0601
Associate
Associate
0 Kudos

Join will not work for if your target table is one of the database tables selected by default in the badi. Create a custom database view or cds view on VBPA with only the key fields and your required fields. Then try the code below. (ZVBPAWE is the view)

 

    INSERT VALUE #( table         = 'ZVBPAWE'
                    field         = 'LAND1'
                    name          = 'ZLAND1' )
      INTO TABLE ct_result_comp.

    INSERT VALUE #( target_field = 'VBELN'
                    source_table = 'VBAK'
                    source_field = 'VBELN' )
      INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_field   = 'POSNR'
                    constant_value = '000000' ) 
      INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_field   = 'PARVW'
                    constant_value = 'WE' ) 
      INTO TABLE lt_join_metadata.

    INSERT VALUE #( target_table  = 'ZVBPAWE'
                    join_metadata = lt_join_metadata )
      INTO TABLE ct_additional_table_metadata.