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: 

writing down a tables content generic

Former Member
0 Kudos

Hi experts,

simple question :

When I start the program to be coded, I enter the name of a r/3 table (such as TSAD2).

I save the name in an ordinary char variable.

How can I display the entire content of the table now?

Remember : It is supposed to be generic, so you can't see the table name as pre-requisit.

My first thought was to save the entire r/3 table into an internal table (to reduce rfc calls and traffic) and to display it via a loop at-iteration, but I fail with retrieving the table content.

REPORT z_smoftables_test.

PARAMETERS : input_tablename type char20.

*call the table namend after the user input and save it

*create a generic structure "like line of r/3 table" ---you have to have called the table before...thats my problem

*loop table into structure and write

Thanks in advance!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

For anything dynamic about data, check articles about RTTS (Run Time Type Services). See [this|http://wiki.sdn.sap.com/wiki/x/1ac] for a quick overview. Basically with that you can retrieve metadata about types, modify them (at least for structures), dynamically create variables, internal tables, ...

It is certainly not an easy subject, but worth investing some time on it.

15 REPLIES 15

Former Member
0 Kudos

Paul,

Another strange question from you... why not use SE16? Are you just trying things out?

You would need to create a dynamic int table using cl_alv_table_create=>create_dynamic_table.

This requires that you build a field catalog - so you will need to get the DB tables field defs to contsruct the Field Catalog.

former_member201275
Active Contributor
0 Kudos

Also I am not sure why you don't just use SE16?

Either that or I think you are probably looking for Field-symbols. In which case I suggest you search this forum as there is plenty of help on this.

0 Kudos

well I am kinda trying things out, but in the end it might be useful.

its going to be a mapping tool for multiple exchange projects and for a hundred of tables it might be nasty to look for their structures.

I was like : type in a random table name and get it displayed (first milestone for me )

0 Kudos

How are you going to know which table name to type in? Either way you are going to have to search for the name you want.... unless I am missing the point.

Either that or I would create the program so that when the user enters a table name it displays it via SE16... that way you have all the dictionary functionality to hand.

0 Kudos

you can use FM; SE16N_INTERFACE but this is not RFC.

Copy into Z and make it an RFC. You can pass the table name and this will display the table as it would in SE16N with ALV.

0 Kudos

Paul,

Well - using the class method that I cited above along with DB tables DD0* (like DD03L, etc) - you can build the field catalog.

The fundamental question is why? Not sure what an "exchange project" is - but you are trying to extract data from SAP to move to a different system? If so - that defeats the whole purpose of why your employer bought SAP. SAP data should stay within SAP. If you need to extract it out tables for external use, you will definitely want to engage your SAP Security team as well as internal/external auditors - before proceeding with any development.

0 Kudos

the user shall type in a name via PARAMETERS

the program, in its final state, is supposed to map some hundred tables :s

fooling around with se16 will take forever then or am I on the wrong track totally?

Former Member
0 Kudos

it is about retrieving several tables from differend erp backends and mapping them into a crm system, and my task is to write a tool that enables us to analyze how many mapping cases exist (it shall be usable for other environments aswell, thats why it has to be generic)

0 Kudos

I might suggest a CALL TRANSACTION to SE16 USING bdc_tab and SKIP FIRST SCREEN - within a LOOP for each table required.

Not sure if you need the output saved locally - or just exposed to the screen.

If you need it saved, you could add that screen processing logic ot the bdc_tab table.

0 Kudos

ohhh sounds great already, going to try that

0 Kudos

Paul,

Not a dumb question - sounds like a daunting task to be honest.

It also sounds riddled with possible issues. I would suggest consulting with a CRM Middleware expert.

Former Member
0 Kudos

well basically se16 does everything I want,

but I need to repeat that for an uncertain amout of tables,

load them into internal tables,

compare their lines and find mapping cases (semantically identical lines).

and for a good usability it would be awesome just to type in some tables names and press "FIND".

I am really sorry if I ask dumb questions, but I have no more than basic abap skills.

0 Kudos

well basically se16 does everything I want,

> but I need to repeat that for an uncertain amout of tables,

> load them into internal tables,

> compare their lines and find mapping cases (semantically identical lines).

>

> and for a good usability it would be awesome just to type in some tables names and press "FIND".

> I am really sorry if I ask dumb questions, but I have no more than basic abap skills.

Well, it is not dumb but just hard digest the requirement.

However, you can refer to the function module 'SE16N_INTERFACE' for reference. you can code pretty much same as in this function module. when you debug this function module, you could see the logic.

Just come down to the comment '..now display the results in a fullscreen ALV-GRID' ...

Go to the subroutine ' Perform display_Standard using i_old_alv i_cwidth_opt_off'

Within this subroutine there is the following code which actually display the content of the table.

*...Now either create editable table or simply send table to the front

perform set_table_for_display using cwidth_opt_off.

Using a Field symbol and structure as the table name. Just go until call method alv_grid->set_table_for_first_display to understand what the function module is doing..

It is creating a dynamic internal table out from selection table and displaying using field catalog.

you will understand if you go through the FM in debug.

Try checking <all_table> from start of function module. This will be filled with the input table content.

Former Member
0 Kudos

Hello,

For anything dynamic about data, check articles about RTTS (Run Time Type Services). See [this|http://wiki.sdn.sap.com/wiki/x/1ac] for a quick overview. Basically with that you can retrieve metadata about types, modify them (at least for structures), dynamically create variables, internal tables, ...

It is certainly not an easy subject, but worth investing some time on it.

Former Member
0 Kudos

http://wiki.sdn.sap.com/wiki/display/Snippets/PrintTableContentswithoutknowingTableNameorStructurebeforeRunTime-2-

thats it... perfect.

I modified it a bit and now it works perfectly for me

if I add a "frontend" for incomming rfc tables and change its output to an ALV grid I'll be fine for now

thank you very much !