i_structure_name in ALV

Question:
Hello,
I have a question about REUSE_ALV_LIST_DISPLAY function.
call function 'REUSE_ALV_LIST_DISPLAY'                               
      exporting                                                       
           i_callback_program = g_repid                               
           i_structure_name   = 'SFLIGHT'                             
           i_save             = 'A'      " A = All => Standard & User 
      tables                                                           
           t_outtab           = gt_sflight.                           
Is i_structure_name can be declared in the program :
DATA: BEGIN OF struc,   
       ...               
      END   OF struc.   
or I have to create it via SE11 ?
Sorry for this silly question, but I don't find an example.
Thank you in advance.
Nickel[/code]
Answer:
Either a dictionary structure or locally defined structure is fine.
Answer:
report balvsd06 no standard page heading.                               
* DB-Table                                                               
tables sflight.                                                         
* Type-pool of ALV                                                       
data : begin of struct,                                                 
       carrid like  sflight-carrid,                                     
       connid type sflight-connid,                                       
       fldate type sflight-fldate,                                       
       end of struct.                                                   
                                                                         
select-options  carrid for sflight-carrid.                               
select-options connid for sflight-connid.                               
select-options fldate for sflight-fldate.                               
* Data to be displayed                                                   
data: gt_sflight like struct occurs 0 with header line.                 
data: g_repid like sy-repid.                                             
*---------------------------------------------------------------------* 
                                                                         
* Selection                                                             
  select carrid connid fldate                                           
          from sflight into table gt_sflight where carrid in carrid     
                                              and   connid in connid     
                                              and   fldate in fldate.   
                                                                         
  g_repid = sy-repid.                                                   
* Call ABAP/4 List Viewer                                               
  call function 'REUSE_ALV_LIST_DISPLAY'                                 
       exporting                                                         
            i_callback_program = g_repid                                 
            i_structure_name   = 'STRUCT'                               
            i_save             = 'A'      " A = All => Standard & User   
       tables                                                           
            t_outtab           = gt_sflight.                             
Here is the code, but my list is empty.
What is wrong ?
regards
Nickel
Answer:
For REUSE*LIST*, parameters I_STRUCTURE_NAME, according to documentation, only accepts dictionary-defined structures.
Before you call REUSE*DISPLAY, do a REUSE*FIELDCAT*MERGE, passing to it g_repid and 'STRUCT'. Pass the resulting FIELDCATALOG table to your *LIST_DISPLAY FM.
Answer:
ALV is supposed to work with either dictionary structure or program structure. SAP recommends that for production programs, you use a dictionary structure.
My observation and experience is that ALV works consistently whenever I use dictionary structure.
When working with program structure, ALV attempts to parse the ABAP program to determine the structure - which, in my opinion, doesn't succeed all the time.
_________________
Sudhi Karkada
Answer:
Thank you guys for your reply.
I'm new in ALV domain, It's a pitty to create a structure in data dictionnary to have a list.
but I will try your solution sy-subrc.
Nickel
Answer:
If you want to use an itab from your program, use REUSE_ALV_FIELDCATALOG_MERGE. SAP reads the program (or TOP include as the documents say) and parses the itab definition. It succeeds where you have defined your fields LIKE or TYPE dictionary fields. If you have locally defined fields like MATNR(1 or ORDER(10), the fieldcatalog returned by the fm has not texts on it. In such cases, loop through the field catalog and modify the descriptions suitably.
At my site, sold-to is called a CLIENT and ship-to is called a PRODUCT. Both are defined LIKE VBAK-KUNNR. SAP will return the same description for both fields. I post-process the fieldcatalog, fill in the right descriptions and then call the REUSE*DISPLAY function module.
Answer:
Hi,
Correct Sy-Subrc but you cannot use 'type'
The variant based on a program-internal table should only be used for
rapid prototyping since the following restrictions apply:
o Performance is affected since the code of the table definition must
always be read and interpreted at runtime.
o Dictionary references are only considered if the keywords LIKE or
INCLUDE STRUCTURE (not TYPE) are used.
regards,
Kevin Hill
Answer:
Hello,
I have tried to test the demo program BALVSD11.
in function module REUSE_ALV_FIELDCATALOG_MERGE, I have replaced the structure 'SIMLISTRUC' in i_structure_name by a structure defined in the program by myself.
data : begin of simlistruc2,                         
        carrid like simlistruc-carrid,               
        carrname like simlistruc-carrname,           
        connid like simlistruc-connid,               
        cityfrom              like simlistruc-cityfrom,     
        airpfrom              like simlistruc-airpfrom,     
        cityto                like simlistruc-cityto,       
        airpto                like simlistruc-airpto,       
        deptime               like simlistruc-deptime,       
        arrtime               like simlistruc-arrtime,       
        distance              like simlistruc-distance,     
        distid                like simlistruc-distid,       
end of simlistruc2.                                 
But the program does not work.
Please tell me why.
Thank you for you help.
PS: I'm in 4.5B
Nickel
Answer:
Hi,
Is my question is not clear, or is it stupid, or you are in holiday ?
Happy new year
Nickel
Answer:
Nickel,
Before posing another question, please do the following....
Go to SE16 - if you have authorization.....
Type in Sflight or all other tables you want the data for....
If it returns with 0 entries.. Go have tea .... Your System was offloaded with these table contents... It happens in many projects....
Else...
Try and retrieve the same data in a non-alv... if you get rows and columns...
We will fix your CODE!!

More Articles:

GRID HEADING?
Search help?
Table Fields Identification?
Activating pricing routine?
How can I Place A Hiearchy Node in my SAP Table Ctrl.?
Sharing FormEndform Between two Function Modules?