Application Development and Automation 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: 
Read only

Cant execute the program. Suspecting REUSE ALV DISPLAY problem.

Former Member
0 Likes
1,676

I cant execute the program. What is the problem? I been facing the alv display problem recently. What is missing?

p/s: Please ignore the unnecessary code.

tables: bsik, bsak, t001, knb1, bsid, kna1, bsad.
TYPE-Pools: slis.
*Data Declaration
TYPES: BEGIN OF wa_display,
         mandt like knb1-mandt,
         kunnr like knb1-kunnr,
         bukrs like knb1-bukrs,
         pernr like knb1-pernr,
        END OF wa_display.

DATA: it_knb1 TYPE STANDARD TABLE OF knb1, "Table with company code and customer code
       wa_knb1 type knb1.
Data: wa_display type wa_display,
       it_display type TABLE OF wa_display.

*ALV Data Declaration
DATA: it_fieldcat       TYPE slis_t_fieldcat_alv,
       wa_fieldcat       TYPE slis_fieldcat_alv,
       g_alv_title       TYPE lvc_title VALUE 'KNB1',
       g_alv_display     TYPE lvc_title VALUE 'ALV Display',
       G_PROGRAM         TYPE sy-repid.

*Start-of-selection.
START-OF-SELECTION.

G_PROGRAM = SY-REPID.

perform get_data.
perform pass_data.
perform fieldcat_init using it_fieldcat.
PERFORM pass_alv.

End-of-SELECTION.

form get_data.
* Select all Company code and Customer code
select *
   into CORRESPONDING FIELDS OF TABLE it_knb1
   from knb1.

endform.

form pass_data.

   LOOP AT it_knb1 into wa_knb1.
     wa_display-mandt = wa_knb1-mandt.
     wa_display-kunnr = wa_knb1-kunnr.
     wa_display-bukrs = wa_knb1-bukrs.
     wa_display-pernr = wa_knb1-pernr.
     APPEND wa_display TO it_display.
     CLEAR wa_display.
   ENDLOOP.

   endform.
Form fieldcat_init using p_fieldcat type slis_t_fieldcat_alv.
   DATA: ls_fieldcat TYPE slis_fieldcat_alv.

   ls_fieldcat-fieldname = 'Client'.
   ls_fieldcat-seltext_m = 'MANDT'.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'Customer Number'.
   ls_fieldcat-seltext_m = 'KUNNR'.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'Company Code'.
   ls_fieldcat-seltext_m = 'BUKRS'.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'Personnel Number'.
   ls_fieldcat-seltext_m = 'PERNR'.
   APPEND ls_fieldcat to it_fieldcat.

   ENDFORM.

FORM pass_alv.
   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = g_program
      I_STRUCTURE_NAME                  = 'it_display'
*     I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = g_alv_title
*     I_GRID_SETTINGS                   =
*     IS_LAYOUT                         =
      IT_FIELDCAT                       = it_fieldcat

     TABLES
       t_outtab                          = it_display
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
             .
   IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.


   ENDFORM.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,643

You inverted the fields fieldname and seltext_m in the field catalog. (You will then be able to display ALV and if any other problem arises, perform The Consistency Check)

Regards,
Raymond


13 REPLIES 13
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,644

You inverted the fields fieldname and seltext_m in the field catalog. (You will then be able to display ALV and if any other problem arises, perform The Consistency Check)

Regards,
Raymond


Read only

0 Likes
1,643

So, u mean I need to add col_pos only, right?

I added col_pos for each of the field but still get error.

This is the error shown:

Runtime errors : getwa_not_assigned

Read only

0 Likes
1,643

Hi

As Raymond mentioned in  fieldname in field catalog pass MANDT and assign the COL_POS value as 1, 2 3 and so on. Plus in the call to REUSE_ALV_GRID_DISPLAY the structure name should be in capital letter you can even comment it.

Thanks

Nabheet

Read only

0 Likes
1,643

I added the col_pos and wrote the structure name in capital letter:

But the runtime error :getwa_not_assigned still occured

----------------------------------------------------------------------------------------------------------------------

i_structure_name   = 'it_display'

-----------------------------------------------------------------------------------------------------------------------

   ls_fieldcat-fieldname = 'Client'.
   ls_fieldcat-seltext_m = 'MANDT'.
   ls_fieldcat-col_pos   = 1.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'Customer Number'.
   ls_fieldcat-seltext_m = 'KUNNR'.
   ls_fieldcat-col_pos   = 2.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'Company Code'.
   ls_fieldcat-seltext_m = 'BUKRS'.
   ls_fieldcat-col_pos   = 3.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'Personnel Number'.
   ls_fieldcat-seltext_m = 'PERNR'.
   ls_fieldcat-col_pos   = 4.
   APPEND ls_fieldcat to it_fieldcat.

Read only

former_member585060
Active Contributor
0 Likes
1,643

Hi,

   Check the building of Fieldcatalog for your IT_DISPLAY table, COL_POS is missing. It will take care of in which coloumn the particular field has to be displayed.

Thanks & Regards

Bala Krishna

Read only

Former Member
0 Likes
1,643

I did the g_program = sy-repid on the first line of start-of-selection.

still got error.

Read only

0 Likes
1,643

Hello,

Write field-catalog as below:

   ls_fieldcat-fieldname = 'MANDT'.
   ls_fieldcat-seltext_m = '
Client'.
   ls_fieldcat-col_pos   = 1.
   APPEND ls_fieldcat to it_fieldcat. 

   clear ls_fieldcat.

   ls_fieldcat-fieldname = '
KUNNR'.
   ls_fieldcat-seltext_m = '
Customer Number'.
   ls_fieldcat-col_pos   = 2.
   APPEND ls_fieldcat to it_fieldcat.

  clear ls_fieldcat.

   ls_fieldcat-fieldname = '
BUKRS'.
   ls_fieldcat-seltext_m = '
Company Code'.
   ls_fieldcat-col_pos   = 3.
   APPEND ls_fieldcat to it_fieldcat.
 
clear ls_fieldcat.


   ls_fieldcat-fieldname = 'PERNR'.
   ls_fieldcat-seltext_m = '
Personnel Number'.
   ls_fieldcat-col_pos   = 4.
   APPEND ls_fieldcat to it_fieldcat.

clear ls_fieldcat.


Read only

0 Likes
1,643

  Hi,

Raymond Giuseppi is absolutely right just switch the fieldname and seltext_m it as follows for all fields it 'll work.
   ls_fieldcat-fieldname =
'MANDT'.
   ls_fieldcat-seltext_m =
'Client'.
   APPEND ls_fieldcat to it_fieldcat.

regards,

Rakesh.





Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,643

To get the actual minimal requirement to build ALV field catalog manually - read Generating the Field Catalog Manually
(As you define fields with like statement refering ddic, fieldname is enough, notice that col_pos is not mandatory )

Regards,
Raymond

Read only

former_member189779
Active Contributor
0 Likes
1,643

This message was moderated.

Read only

Private_Member_49934
Product and Topic Expert
Product and Topic Expert
0 Likes
1,643

A big mistake though silly .

You interchange the field name and field description while building the fild catalob

The form should be as below.   <removed by moderator>

Form fieldcat_init using p_fieldcat type slis_t_fieldcat_alv.
   DATA: ls_fieldcat TYPE slis_fieldcat_alv.

   ls_fieldcat-fieldname = 'MANDT'.
   ls_fieldcat-seltext_m = 'Client'.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'KUNNR'.
   ls_fieldcat-seltext_m = 'Customer Number'.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'BUKRS'.
   ls_fieldcat-seltext_m = 'Company Code'.
   APPEND ls_fieldcat to it_fieldcat.

   ls_fieldcat-fieldname = 'PERNR'.
   ls_fieldcat-seltext_m = 'Personnel Number'.
   APPEND ls_fieldcat to it_fieldcat.

   ENDFORM.

Message was edited by: Thomas Zloch

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,643

Dear Swapna, Satvik, Kumar, Rakesh,

What is the use suggesting the same thing. How are your suggestion's different from Raymond's suggestion ?

@Kumar - Asking for points is a serious problem here Read the forum rules.

Read only

0 Likes
1,643

Hi Keshavdas. I agree with you. When I open the thread no reply was there and I went for lunch . I posted in the thread after returning back unaware that it was already posted.