‎2007 Apr 17 8:20 PM
Hi :
I am trying to pull some fields from data base and display in alv.My program is syntactically correct but its not retreving any fields from the database.
Below is my program.I would appreciate if anyone can figure out the error.
REPORT zska_mm_create_po_from_pr NO STANDARD PAGE HEADING MESSAGE-ID
zska .
TABLES: eban.
*data declarations.
TYPES : BEGIN OF t_prdata,
lifnr LIKE eban-lifnr,
matnr LIKE eban-matnr,
menge LIKE eban-menge,
werks LIKE eban-werks,
ekorg LIKE eban-ekorg,
frgdt LIKE eban-frgdt,
END OF t_prdata.
DATA : BEGIN OF it_output OCCURS 0,
lifnr TYPE eban-lifnr,
matnr TYPE eban-matnr,
menge TYPE eban-menge,
werks TYPE eban-werks,
ekorg TYPE eban-ekorg,
frgdt TYPE eban-frgdt,
ebeln TYPE eban-ebeln,
ebelp TYPE eban-ebelp,
bedat TYPE eban-bedat,
bsmng TYPE eban-bsmng,
END OF it_output.
TYPE-POOLS : slis.
DATA : repid LIKE sy-repid.
DATA : it_prdata TYPE TABLE OF t_prdata.
*alv grid instance ref.
DATA l_grid TYPE REF TO cl_gui_alv_grid.
*custom control
DATA l_custom_control TYPE scrfname VALUE 'CC_ALV'.
*custom container
DATA l_ccontainer TYPE REF TO cl_gui_custom_container.
*filed catalog
DATA l_fieldcat TYPE lvc_t_fcat.
*layout structure
DATA l_layout TYPE lvc_s_layo.
*selection screen
PARAMETERS : r_poauto RADIOBUTTON GROUP g1 USER-COMMAND radio DEFAULT
'X'.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_lifnr FOR eban-lifnr MODIF ID sc1,
s_matnr FOR eban-matnr MODIF ID sc1,
s_ekorg FOR eban-ekorg MODIF ID sc1,
s_date FOR eban-frgdt DEFAULT sy-datum MODIF ID sc1.
PARAMETERS : p_werks LIKE eban-werks MODIF ID sc1.
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS: r_pofile RADIOBUTTON GROUP g1.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
PARAMETERS p_file TYPE rlgrap-filename MODIF ID sc2.
SELECTION-SCREEN END OF BLOCK b2.
*selection screen events
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF r_pofile EQ 'X'.
IF screen-group1 = 'SC1'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDIF.
IF r_poauto EQ 'X'.
IF screen-group1 = 'SC2'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
SELECT lifnr matnr menge werks ekorg frgdt FROM eban INTO TABLE
it_prdata WHERE
lifnr IN s_lifnr AND
matnr IN s_matnr AND
werks = p_werks AND
frgdt IN s_date
AND blckd = ''
AND statu = 'N'.
IF sy-subrc <> 0.
MESSAGE i002(zska).
ENDIF.
COMMIT WORK AND WAIT.
CALL SCREEN 100.
*&----
*
*& Module DISPLAY_ALV OUTPUT
*&----
*
text
*----
*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'Z_SKA_ALV'.
SET TITLEBAR 'Z_SKA_ALV_DISPLAY'.
IF l_grid IS INITIAL.
*custom conatiner instance
CREATE OBJECT l_ccontainer
EXPORTING
PARENT =
container_name = l_custom_control
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*alv grid instance
CREATE OBJECT l_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = l_ccontainer
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*PREPARING FIELD CATALOG
PERFORM prepare_field_catalog CHANGING l_fieldcat.
*PREPARING FILED STRUCTURE
PERFORM prepare_layout CHANGING l_layout.
CALL METHOD l_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = l_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = it_prdata
it_fieldcatalog = l_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE.
CALL METHOD l_grid->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
finished = 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.
ENDIF.
ENDMODULE. "STATUS_0100 OUTPUT
*&----
*
*& Form PREPARE_FIELD_CATALOG
*&----
*
text
*----
*
<--P_L_FIELDCAT text
*----
*
FORM prepare_field_catalog CHANGING p_l_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'LIFNR'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
ls_fcat-fieldname = 'MENGE'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
ls_fcat-fieldname = 'WERKS'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
ls_fcat-fieldname = 'EKORG'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
ls_fcat-fieldname = 'FRGDT'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
ENDFORM. " PREPARE_FIELD_CATALOG
*&----
*
*& Form PREPARE_LAYOUT
*&----
*
text
*----
*
<--P_L_LAYOUT text
*----
*
FORM prepare_layout CHANGING p_s_layout TYPE lvc_s_layo.
p_s_layout-zebra = 'x'.
p_s_layout-grid_title = 'create po from pr'.
p_s_layout-keyhot = 'x'.
ENDFORM. " PREPARE_LAYOUT
*&----
*
*& Module USER_COMMAND_0100 INPUT
*&----
*
text
*----
*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
SET SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'save'.
PERFORM create_po.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&----
*
*& Form CREATE_PO
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
FORM create_po .
ENDFORM. " CREATE_PO
‎2007 Apr 17 9:08 PM
Hi Experts,
Still im struck with the same problem.When i debug , the cursor pointing to the mssg class after the select statement.
do i need to write individual select statements for each and evry field which i want to display and valuate them.
Thx.
Raghu
‎2007 Apr 17 8:28 PM
You use check your query to table EBAN...and also, you should defined your catalog like this....
ls_fcat-COL_POS = '1'.
ls_fcat-fieldname = 'LIFNR'.
ls_fcat-ref_table = 'EBAN'.
APPEND ls_fcat TO p_l_fieldcat.
Greetings,
Blag.
‎2007 Apr 17 8:29 PM
Have you checked to make sure that there are entries in table eban that meet your selection criteria? Put a breakpoint right before your select statement to check that it is pulling information into your table it_prdata. If it looks like entries are being found (or you know that there are records that fit your selection criteria), try changing your select statement to this:
SELECT lifnr matnr menge werks ekorg frgdt FROM eban
INTO (t_prdata-lifnr,t_prdata-matnr,t_prdata-menge,t_prdata-werks,t_prdata-ekorg,t_prdata-frgdt)
WHERE
lifnr IN s_lifnr AND
matnr IN s_matnr AND
werks = p_werks AND
frgdt IN s_date
AND blckd = ''
AND statu = 'N'.
APPEND t_prdata.
CLEAR t_prdata.
ENDSELECT.
I hope this helps.
- April King
‎2007 Apr 17 8:29 PM
You program works very good for me. I did have to comment out this line in the WHERE clause, because that field doesn't exist in the database in my system.
select lifnr matnr menge werks ekorg frgdt from eban into table
it_prdata where
lifnr in s_lifnr and
matnr in s_matnr and
werks = p_werks and
frgdt in s_date
* and blckd = '' "<- Right Here
and statu = 'N'.Are you sure that this is ok here, maybe try to do this.
select lifnr matnr menge werks ekorg frgdt from eban into table
it_prdata where
lifnr in s_lifnr and
matnr in s_matnr and
werks = p_werks and
frgdt in s_date
and blckd = space " LIKE THIS
and statu = 'N'.Regards,
RIch Heilman
‎2007 Apr 17 9:08 PM
Hi Experts,
Still im struck with the same problem.When i debug , the cursor pointing to the mssg class after the select statement.
do i need to write individual select statements for each and evry field which i want to display and valuate them.
Thx.
Raghu
‎2007 Apr 17 9:18 PM
‎2007 Apr 17 9:29 PM
Hi Rich,
Its wokin now, when i enter value for plant in selection screen.
Thanks for the input, full points r rewarded.
~Raghu