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: 

How to add a coloumn to an existing Zreport?

Former Member
0 Kudos

Hi all

I have a requirement where I have to add a column to an existing Zreport. I have the code with me and it has no technical specification nor does have proper comments in the code.

I am trying to figure out and I am very much new to reporting.

Can some one tell me where in the code should I look to add a new column to the report,

The report more over brings the o/p in excel sheet.

Any hints will be highly appreciated. Please help. I never worked on reports earlier.

Regards,

Jessica Sam

13 REPLIES 13

anuj_srivastava
Active Participant
0 Kudos

Hi Jessica ,

You need to add one more field to ur existing structure or the internal table which u r using for getting the output into the excel file.

Once u have added that field you cn get the field into ur excel file.

regards,

Anuj

Former Member
0 Kudos

Hi Jessica,

if you want to add new column to the report output..

first you need to add extra field to the output table..

Next write logic to fill the column or field..

next append new field to the field catalog.

then you will get new column in the existing zreport.

Regards,

Prabhu

former_member212002
Active Contributor
0 Kudos

Hi Jessica,

When we are working with reports,most of the time we deal with internal tables or structures,so adding a new column to the existing report means editing the internal table or the structure we have.

For eg : We have a Students table in the ddic namely zstdu and we want to access its name and standard, so for this we need to do something like this.


Tables : zstdu.
data : begin of itab occurs 0,
         name like zstdu-name,
         standard like zstdu-std,
        end of itab,

Now if we want to add one more column to this report ,say roll no from the ddic table then we need to do something like this.


Tables : zstdu.
data : begin of itab occurs 0,
         name like zstdu-name,
         standard like zstdu-std,
         rollno like zstdu-rollno " New column to the report.
        end of itab,

So for your requirement you need to find the appropriate internal table or structure where you need to add new columns/fields.

Regards

Abhinab Mishra

0 Kudos

Mishra,

Thanks to you and evrybosy who responded....

The code is written by some body and there is no documentation/comment lines in the code and so i am finding it hard to figure out.

Can you first tell me how to add the heading for the new column in report o/p.

Then once i add the heading for the column in report o/p next i will jump into finding the internal table and adding a new field to extract data into this column.

to add heading for new clolumn where should i look in code? is it Top-of-page or start of selection?

please help me as i am new to reports.

Regards,

Jessica Sam

0 Kudos

Hi Jessica,

If you talking about report heading then the event Top-Of-Page with an addition no standard page heading to the report name

for eg :-


report zname no standard page heading

Regards

Abhinab Mishra

0 Kudos

All,

The report typically was as follows



1) selection-screen begin of block q1
    select-options
-------------------------------------
-------------------------------------
    selection-screen end of block q1

2) Initialization.

3) start-of-selection.

--------------------------select stmts to fecth the data-----------------

end-of-selection

4) Top-of-page.
---------------------------
-----------------

5) CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_PLATFORM

6)  CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'



Any clues where i should be looking to add a new column to the report output and also give a name/heading to the new column as "Dicount Percentage".

Prabhu as you mentioned i tried looking for "fieldcat" but could not find it any where in the code.

so i am thinking that it is not an ALV. but the output of the report comes in excel sheet so not quite sure if it is simple report or an ALV

Regards,

Jessica Sam

0 Kudos

Hi Jessica,

If you want your column to be a parameter then declare it within the selection screen of your report, or else

look for the data declaration part of the report.

Regards

Abhinab

0 Kudos

Abhinav thanks a lot for the help.

I dont need the extra column to be a part of my selction screen. I just want to add an extra column to my report output whihc says "Discount" and the column should be filled with data fetched from VBAK table.

So which part should i look to add the new column? when you said in "look in data declartion"...means you mean that i need to add first a field to internal table?

say for i do that ...then where should i be adding the heading as "Discount" such that my new column of the report output has the column name as "Discount"

Regards,

Jessica

0 Kudos

Hello Again,

For this there is a simple way use the Under addition like this :

For eg :-


tables : zma
data:begin of itab occurs 0,
       zma like zma-ma,
       end of itab.

write : itab-zma under 'Discount'.

you can place the system variable sy-uline also for look and feel.

Regrds,

Abhinab Mishra

0 Kudos

As per your query i understood the output is coming directly in the EXCEL and not as normal output list report.

Then you need to look into fm CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

and check for tables parameters

DATA_TAB

FIELDNAMES

How these are getting filled.

PS If you need proper replies please ask questions in details with code, so that members understand properly

Former Member
0 Kudos

HI Jessica,

try this..

change the field catalog table name and work area according to you r report...


    wa_fieldcat-fieldname = 'EBELN'.       "New field Name
    wa_fieldcat-col_pos = '1'.                  "Column Position
    wa_fieldcat-seltext_l = 'PO Number'.  "text heading you wan tot display
    append wa_fieldcat to it_fieldcat.

Jessica first add new field in output table next add field in field catalog otherwise it goes to dump.

regards,

Prabhudas

Former Member
0 Kudos

Solved

Former Member
0 Kudos

Solved