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: 

How to send ALV Report Data in Batches in AL11 in CSV Format?

0 Kudos
1,007

Hi

I have a requirement that I have to upload Data in AL11 (CSV Format), which will come from an ALV Report. Suppose

If My ALV has 15000 records, then it should create three CSV file in AL11, each file contain 5000 records.

Need urgent help !

6 REPLIES 6

Sandra_Rossi
Active Contributor
0 Kudos
774

I don't see any problem in doing that. What is your issue? What don't you already know?

raymond_giuseppi
Active Contributor
774

What were you unable to do, there are already many questions/blogs/wiki/sample on how to get the data of an ALV grid and how to convert to csv?

0 Kudos
774

I have converted this and send to AL11, My ques is how to generate seperate file in AL11 like

file1 has 1 to 5000 records.

file 2 has 5001 to 10000 records

file 3 has 10001 to 15000 records.

in AL11. ?

please help.

Sandra_Rossi
Active Contributor
774

Reusable code in the middle:

TYPES: BEGIN OF ty_package,
         from TYPE i,
         to   TYPE i,
       END OF ty_package,
       ty_packages TYPE STANDARD TABLE OF ty_package WITH EMPTY KEY.

SELECT * FROM mara INTO TABLE @DATA(table).

DATA(number_of_items) = lines( table ).
DATA(package_size) = 5000.

DATA(packages) = REDUCE ty_packages(
    LET number_of_packages = ( ( number_of_items - 1 ) DIV package_size ) + 1 IN
    INIT itab = VALUE ty_packages( )
         from = 1
    FOR i = 1 WHILE i <= number_of_packages
    NEXT itab = VALUE #( BASE itab
                ( from = from
                  to   = nmin( val1 = number_of_items val2 = from + package_size - 1 ) ) )
         from = from + package_size ).

LOOP AT packages REFERENCE INTO DATA(package).
  OPEN DATASET ... FOR OUTPUT ...
  LOOP AT table FROM package->from TO package->to REFERENCE INTO DATA(line).
    TRANSFER line->* TO ...
  ENDLOOP.
  CLOSE DATASET ...
ENDLOOP.

0 Kudos
774

Hi Sandra Rossi

Can you post the complete code here ?

0 Kudos
774

arvindkr276 As far as I understand, based on the question asked (= how to split an internal table into packages; it's not about DATASET, it's not about batches, it's not about CSV format), the answer doesn't need to be completed. Ask your own question, and indicate what you are missing (if needed, you may insert a link to this thread).