cancel
Showing results for 
Search instead for 
Did you mean: 

Read SAP tables

Former Member
0 Kudos

Hi all,

I have a question...

I would like to get the data of a structure table (table not in our Oracle database) from SAP in a way so the data will be available in PHP. I was thinking about getting the data in an array, or something like that...

I've tried the RFC_READ_TABLE function, but it is not recommended by SAP. It also has the problem that it causes the DATA_BUFFER_EXCEEDED exception quiet easily.

Anyone has some ideas or tips on how I could do this.

BTW, In first place I would like to get the data from the BSEG table in PHP.

I'm using the saprfc 1.4.1 module and PHP 5.1.2 on an Apache2 Linux server.

Many thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

There are one or two ways of doing this.

1. Search if a ABAP FM or BAPI already exisits (probably not)

2. If you have the ability to create an ABAP function, create a simple ABAP function (set as remote enabled or as a web service) that will gather the data for you

Another option is executing ABAP dynamically, which can be tricky. What table is BSEG? I've not heard of that, is it part of a module?

Former Member
0 Kudos

Thanks for the suggestions Craig...

I havn't found a FM for my problem. (except for RFC_READ_TABLE, which I and SAP don't really like).

I also thought about writing my own function for this, but I was just curious if there maybe allready is an easy way to read data from sap tables with saprfc.

BSEG is a structure table in SAP with description "Accounting Document Segments".

It has something to do with the processing of documents in the Accounting modules. I don't really know the details.

Thanks.

Former Member
0 Kudos

I thought it might be a module, I've no access to a system with that.

Most people seem to basically copy and modify RFC_READ_TABLE to suit their needs or simply create a new more streamlined FM that will gather the specific data you need.

former_member583013
Active Contributor
0 Kudos

I agree with Craig, the best choice here, is to copy and modify the FM according to your neeeds. For example, i modified <b>RFC_READ_TABLE</b> because i need to know which fields of a table are being used as primary keys.

Greetings,

Blag.

Former Member
0 Kudos

Actually in this case I would just write a FM that does the select on the your table the rest of the overhead from RFC_READ_TABLE isn't really needed.

marilyn_pratt
Active Contributor
0 Kudos

BSEG is a cluster table part of the Accoumting Module in old speak

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks for all the awnswers, guys...

I like the idea of Craig to put a "simple select" in a function (maybe with some "TABLE" for options).

If I do it like that, what is the best way to export it to an array in PHP?

Is it the best way to do it like they do it in RFC_READ_TABLE?

Thanks.

Former Member
0 Kudos

That way or if you are familiar with web services you could call it as a web service in PHP (less coding).

marilyn_pratt
Active Contributor
0 Kudos

A few words of caution.

The famous BSEG table is a cluster table.

It is as was correctly stated part of the Accounting Document Segment. It is part of the Pool cluster RFBLG and lives in the package: FBAS (Financial accounting 'Basis').

You can't read a cluster table exactly the way you read a database (old speak, transparent table).

You can use a program to read called RFPPWF05

Note 435694: Display BSEG item by calling FB09D (modified FB09)

Other possiblity: Other possibility: CALL DIALOG 'RF_ZEILEN_ANZEIGE', but since this is a dialog I don't think this would work.

In any event go to FBAS Package (development class) to see your business objects, class library and functions.

Marilyn

Former Member
0 Kudos

That of course makes it harder.

However with the nice info there from Marilyn you should be able to look into the DIALOG and see how it is being called there, or as Marilyn suggests (better way) go to the package and see what FM's or BAPI's are avaialble.

marilyn_pratt
Active Contributor
0 Kudos

I would also take a quick look at the feature (Blag's) on the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/developerareas/abap">ABAP page</a>

It links to a blog by <a href="/people/sap.user72/blog/2004/06/19/how-i-started-with-sap-web-development with a comment by Thomas Jung that clearly says:

You might want to mention OSS note 382318 where SAP tells customers not use use function module RFC_READ_TABLE. The following is from that OSS note:

The scope of function module RFC_READ_TABLE is very restricted. E.g.,

due to the fixed maximum row size only smaller tables can be accessed.

There are several data types that cannot be handled, and also there are

doubts regarding the Unicode compatibility of the function module.

However, all this is quite immaterial, because the function is not meant

to be publicly used anyway. It was only created to be used as a sample

in various training courses, and is clearly flagged as "not released for

customer".

Solution

Do not use function module RFC_READ_TABLE in the first place!

I think we understand that the new way to go is through Web Services. There is a web service repository which has links to various RFCs designed for business purposes.

I would investigate that avenue thouroghly.

marilyn_pratt
Active Contributor
0 Kudos

One more thing thrusting us happily into the "future" rather than the archeology of the past, heavens BSEG read, would be to look at the ESA Preview. You can see that there are enterprise services for doing exactly what it is you would like to do.

Home > Accounting Document Processing > General Ledger Processing Enterprise Service > GLAccount Current Balance Query Response .<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/esapreviewsystem">see ESA Preview System</a>