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: 

FM which read from SAP spool and to construct a table

Former Member
0 Kudos

Hi experts,

I'm now looking for a function which read a SAP spool out table and to construct a new table.

The spool out table contains only one zone inside which there are "|". For exemple:

Line Text

1 Title

2 AA|BB|CC|DD

3 EE|FF|GG|HH

Now I need a fonction module which can read this table in exporting a new one seperated by the "|". That is to say, the result which I need should be :

zone1 zone2 zone3 zone4

Title

AA BB CC DD

EE FF GG HH

Could anyone tell me the name of the right function module which will help me the do that ?

Very thanks!

Nata

1 ACCEPTED SOLUTION

satyajit_mohapatra
Active Contributor
0 Kudos

Use FM 'RSPO_RETURN_ABAP_SPOOLJOB' to read the spool contents by passing spool number. Based on the output internal table, you can arrange the content as per requirements in a new internal table. The spool must be a ABAP list.



CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
  EXPORTING
    rqident = 26751 "ABAP List Spool No
  TABLES
    buffer  = int_list. <------------Internal table with ABAP list spool contents

6 REPLIES 6

satyajit_mohapatra
Active Contributor
0 Kudos

Use FM 'RSPO_RETURN_ABAP_SPOOLJOB' to read the spool contents by passing spool number. Based on the output internal table, you can arrange the content as per requirements in a new internal table. The spool must be a ABAP list.



CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
  EXPORTING
    rqident = 26751 "ABAP List Spool No
  TABLES
    buffer  = int_list. <------------Internal table with ABAP list spool contents

0 Kudos

Thanks Satyajit,

In fact I used the 'RSPO_RETURN_ABAP_SPOOLJOB' and I gave the right spool number to rqident. But instead of export a table which has the same type defined in spool number, it gives me a table which has only one string zone. I don't know why ?

To clear my question, the table type defined in the abap list number is like below who has 7 zone:

Domaine Domaine (Lib.) Sous-domaine Equipe NNI Nom Prénom

But in output, it changes to :

Domaine|Domaine (Lib.)|Sous-domaine|Equipe|NNI|Nom|Prénom

and it is the only zone TXT[C(1024)] !

I do not reach to understand why. Could you help me ? Thanks!

0 Kudos

The FM 'RSPO_RETURN_ABAP_SPOOLJOB' will give you the output as a text table.

In your case, if the output is displayed as

A|B|C|D

1|2|3|4

the FM will return two lines in the internal table as

First Line A|B|C|D

Second Line 1|2|3|4

As per my understaing, you need an internal table with fields A,B,C,D and values 1,2,3,4 respectively.

I'm not sure any readymade FM is available to achieve this. But, once you get the text table from FM 'RSPO_RETURN_ABAP_SPOOLJOB, you can process it and create a new internal table as per your requirement.

Are there fixed number of fields or it can change dynamically?

If the fields are fixed say 4, you can create an internal table with these 4 fields A,B,C,D and pass the values to it using SPLIT string statement ignoring the header/first line of text table.

If the fields are dynamic, you need to create a dynamic internal table based on the header and then pass the values to it.

0 Kudos

Thanks Satyajit,

Actually the fields is dynamic. I have no idea in creating a dynamic internal table and I searched for help. It seems there is a method "cl_alv_table_create=>create_dynamic_table which" would be useful. Could you tell me if it is the right one which will help me and, if yes, do you have a small example to show me how it works ? Thanks!

0 Kudos

Check this link for creation of dynamic internal tables.......

https://wiki.sdn.sap.com/wiki/display/ABAP/Dynamic%20Internal%20table

I think, in your case, you must be knowing the field attributes like type,length etc. You can pass the same directly.

anup_deshmukh4
Active Contributor
0 Kudos

if you want to have a Dynamic Internal table you can use RTTS ( runtime type services ) you can refer to the below links

http://wiki.sdn.sap.com/wiki/display/ABAP/RuntimeTypeServices+%28RTTS%29

http://wiki.sdn.sap.com/wiki/display/Snippets/StepstoCreateTypeDynamically

Hope it helps..!

Anup