2012 Mar 28 9:04 AM
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.
2012 Mar 28 9:16 AM
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
2012 Mar 28 9:16 AM
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
2012 Mar 28 9:28 AM
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
2012 Mar 28 9:35 AM
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
2012 Mar 28 9:51 AM
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.
2012 Mar 28 9:17 AM
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
2012 Mar 28 9:57 AM
I did the g_program = sy-repid on the first line of start-of-selection.
still got error.
2012 Mar 28 10:11 AM
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.
2012 Mar 28 9:58 AM
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.
2012 Mar 28 10:06 AM
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
2012 Mar 28 10:11 AM
2012 Mar 28 10:11 AM
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
2012 Mar 28 10:32 AM
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.
2012 Mar 28 10:47 AM
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.