Skip to Content
avatar image
Former Member

how to specify PACKAGE SIZE for to RFC_READ_TABLE from PyRFC?

I'm trying to use PyRFC to extract large tables via RFC_READ_TABLE (due to an uncooperative/unsupportive basis team).

I know that RFC_READ_TABLE supports calling it with PACKAGE SIZE since ERPConnect does it by default.

In Python for Basis (Part 1) , I learned how to specify an Open SQL where clause using the OPTIONS:


result = connector.call('RFC_READ_TABLE',

                       QUERY_TABLE=tablename,

                       DELIMITER=delimiter,

                       OPTIONS = [{'TEXT':where_clause}])


Is there a way, and how to specify PACKAGE SIZE in this case?

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jun 12, 2014 at 04:04 AM

    Hi,

    the package size works, but you need to call the function module multiple times in a loop. Here's an excerpt of the attached script:

    recordcounter = 1          #needs to be >0 to get the while loop going

    iteration = 0              #the number of times the function module got called

    while recordcounter > 0:  #as long as the function module calll returns rows...

        tempresult = self.call('RFC_READ_TABLE',             

                                ROWSKIPS=iteration*fetchsize,  #defines the number of rows to skip

                                **parameters)

        iteration=iteration+1  #increase the iteration

        data = tempresult['DATA']    #assign the returned rows to a variable

        if len(data) > 0:      #have there been any rows?

            for row in data:      #Do something with them

                ...

        else:

            recordcounter=0    #set recordcounter to 0 to end the while loop.

    The script is far away from being perfect. It doesn't deal with RAW fields and the data types it returns are all strings. It does what I needed it to do but it may not be sufficient for what you may be trying to achieve.

    Best regards

    Lars

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Ok I think I figured it out.

      FIELDS must use the returned FIELDS structure (an array of dicts), so something like parameters['FIELDS']=[{'FIELDNAME':'MANDT''}, {'FIELDNAME':'BUKRS'}] works.