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: 

Two Dimensional Report - With FTP download and formatting in EXCEL

vivekkrishnan
Active Participant
0 Kudos

Hi all,

I have a ztable with customer,daily quantity , date as columns. I need to make a report with date as rows and customer as columns . If a new customer is added in the ztable , one more column should come in the report.

Basically the internal table should change <b>dynamically</b>.

I have to download this report into FTP and should save as .xls file. All formatting that are there in SAP has to appear in the Excel Sheet also.

Is there any function module for Dynamic Internal Tables and make <b>formatting changes in EXCEL</b> ??

Thanks in Advance..

Vivek Krishnan

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos

CREATE DATA <REF> TYPE <TYPE TABLE> TABLE OF <TYPE LINE>

[WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n].

For example:

DATA: my_table TYPE REF TO data.

DATA: table_name(30).

FIELD-SYMBOLS: <my_table> TYPE table.

table_name = 'MARA'.

CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).

You can also use LIKE if you want to create a table like a structure defined in program:

CREATE DATA <REF> LIKE <TYPE TABLE> TABLE OF <TYPE LINE>

but now it has to indicate explicitly the structure.

DATA: BEGIN OF itab,

field1,

field2,

END OF itab.

CREATE DATA my_table LIKE STANDARD TABLE OF itab.

But you can use this statament:

TYPES: BEGIN OF ty_itab,

field1,

field2,

END OF ty_itab.

table_name = 'TY_ITAB'.

CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).

Regards,

Ravi

4 REPLIES 4

former_member181962
Active Contributor
0 Kudos

CREATE DATA <REF> TYPE <TYPE TABLE> TABLE OF <TYPE LINE>

[WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n].

For example:

DATA: my_table TYPE REF TO data.

DATA: table_name(30).

FIELD-SYMBOLS: <my_table> TYPE table.

table_name = 'MARA'.

CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).

You can also use LIKE if you want to create a table like a structure defined in program:

CREATE DATA <REF> LIKE <TYPE TABLE> TABLE OF <TYPE LINE>

but now it has to indicate explicitly the structure.

DATA: BEGIN OF itab,

field1,

field2,

END OF itab.

CREATE DATA my_table LIKE STANDARD TABLE OF itab.

But you can use this statament:

TYPES: BEGIN OF ty_itab,

field1,

field2,

END OF ty_itab.

table_name = 'TY_ITAB'.

CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).

Regards,

Ravi

0 Kudos

Hi Ravi,

My internal does not resemble a standard table or my Ztable , its columns increased whenever the data in the Ztable changes . So if a new customer is added in the table data , a new column has to appear on my internal table ..

hymavathi_oruganti
Active Contributor
0 Kudos

for dynamic columns, i am explaining u how to create with an exmaple, check it,

suppose itab has fields A, B, C.

SO ITAB-C HAS THE VALUES OF C. NOW WE WANT A TABLE WITH VALUES OF C RIGHT!!.

NOW BUILD A FIELDCATALOG LIKE BELOW.

LOOP AT ITAB.

LS_FIELDCAT-FIELDNAME = ITAB-C.

LS_FIELDCAT-COL_TEXT = ITAB_C.

APPEND LS_FIELDCAT TO LT_FIELDCAT.

ENDLOOP.

DATA: DREF TYPE REF TO DATA.

FIELD-SYMBOLS: <TEMP_TAB> TYPE ANY.

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = LT_LVCFIELDCAT

IMPORTING

EP_TABLE = DREF.

ASSIGN dref->* TO <TEMP_TAB>.

<TEMP_TAB> IS THE REQUIRED DYNAMIC INTERNAL TABLE.

NOW IF U WANT TO FILL THE DYNAMIC INTERNAL TABLE.

DO AS BELOW..

DATA: WA_DREF TYPE REF TO DATA.

FIELD-SYMBOLS: <WA_TAB> TYPE ANY.

CREATE DATA WA_DREF LIKE LINE OF <TEMP_TAB>.

ASSIGN WA_DREF->* TO <WA_TAB>.

FIELD-SYMBOLS: <FS1>, <FS2>.

LOOP AT ITAB.

ASSIGN COMPONENT ITAB-C OF STRUCTURE <WA_TAB> TO <FS1>.

<FS1> = {SOME VALUE}.

APPEND <WA_TAB> TO <TEMP_TAB>.

ENDLOOP.

vivekkrishnan
Active Participant
0 Kudos

We used sy line and field symbols and its done.