Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP ABAP '&PC' Export to file causes right-most column to turn into first row

0 Kudos

I have a report that generates this ALV output:

When I click on the default 'Export to file' button and export to an unconverted text file, this is what gets downloaded: (the right-most ItemNo column gets written as the first row, and notification does not get written)

Why is this happening? I am calling the default '&PC' SAP export button, so there is no custom export code.

CODE:

In the report, we have an itab that gets populated: i_output, that is type table of structure t_output.

BEGIN OF t_output,
   qmnum TYPE afih-qmnum,
   fenum TYPE plmm_audit_act-fenum,
END OF t_output.

DATA: i_output TYPE STANDARD TABLE OF t_output,
      i_fieldcat TYPE slis_t_fieldcat_alv,
      w_fieldcat TYPE slis_fieldcat_alv.<br>

Then we create a fieldcatalog and pass all this to the 'reuse_alv_grid_display'. We also have a pf--status where the standard '&PC' export button was added to

CLEAR w_fieldcat.
w_fieldcat-col_pos = 1.
w_fieldcat-fieldname = 'QMNUM'.
w_fieldcat-seltext_m = 'Notification'
w_fieldcat-tabname = 'AFIH'
w_fieldcat-ref_tabname = 'AFIH'
w_fieldcat-red_fieldname = 'QMNUM'
w_fieldcat-outputlen = 12
append w_fieldcat to i_fieldcat.

CLEAR w_fieldcat.
w_fieldcat-col_pos = 2.
w_fieldcat-fieldname = 'FENUM'.
w_fieldcat-seltext_m = 'ItemNo'
w_fieldcat-tabname = 'PLMM_AUDIT_ACT'
w_fieldcat-ref_tabname = 'PLMM_AUDIT_ACT'
w_fieldcat-red_fieldname = 'FENUM'
w_fieldcat-outputlen = 4
append w_fieldcat to i_fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
      i_bypassing_buffer       = 'X'
      i_callback_program       = sy-repid
      i_callback_pf_status_set = 'ZSTATUS'
      it_fieldcat              = i_fieldcat
   TABLES
      t_outtab                 = i_output.<br>

What can be the cause of this issue? I've done export buttons before plenty of times but have never encountered a partially transposed output.

THANK YOU

1 REPLY 1

Sandra_Rossi
Active Contributor
0 Kudos

I'm a little bit surprised what you obtain in text format. What I obtain makes sense:

30.05.2022                     Report Title                                    1
--------------------------------------------------------------------------------
--------------------------------------------------------------
|ID|Airline             |Curr.|Airline URL                   |
--------------------------------------------------------------
|AA|American Airlines   |USD  |http://www.aa.com             |
|AC|Air Canada          |CAD  |http://www.aircanada.ca       |
--------------------------------------------------------------
Maybe prefer using &XXL instead of &PC, which is XLSX export.