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

alv display

Former Member
0 Likes
948

Hi ,

I am trying to create purchase orders using bdc on me21n and also using " bapi_create_po1".Before creating PO , I want to display the extracted data in alv display format.My program is syntactically correct but its not displaying the data.

i would appreciate if some one can help me in this.

Below is the code which should extract data and display in alv .

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.

DATA : ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

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.

repid = sy-repid.

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 eban~blckd = ''

AND eban~statu = 'N'.

if sy-subrc <> 0.

message i002(zska).

endif.

*&----


*

*& Module DISPLAY_ALV OUTPUT

*&----


*

  • text

*----


*

MODULE display_alv OUTPUT.

PERFORM display_alv.

ENDMODULE. " DISPLAY_ALV OUTPUT

*&----


*

*& Form DISPLAY_ALV

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM display_alv .

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.

ENDFORM. " DISPLAY_ALV

*&----


*

*& 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 = 'BANFN'.

ls_fcat-ref_table = 'EBAN'.

APPEND ls_fcat TO p_l_fieldcat.

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 = ''.

p_s_layout-grid_title = 'create po from pr'.

p_s_layout-keyhot = ''.

ENDFORM. " PREPARE_LAYOUT

*&----


*

*& Module USER_COMMAND_0100 INPUT

*&----


*

  • text

*----


*

MODULE user_command_0100 INPUT.

CLEAR ok_code.

CASE save_ok.

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

Hi ,

I am trying to create purchase orders using bdc on me21n and also using " bapi_create_po1".Before creating PO , I want to display the extracted data in alv display format.My program is syntactically correct but its not displaying the data.

i would appreciate if some one can help me in this.

Below is the code which should extract data and display in alv .

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.

DATA : ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

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.

repid = sy-repid.

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 eban~blckd = ''

AND eban~statu = 'N'.

if sy-subrc <> 0.

message i002(zska).

endif.

*&----


*

*& Module DISPLAY_ALV OUTPUT

*&----


*

  • text

*----


*

MODULE display_alv OUTPUT.

PERFORM display_alv.

ENDMODULE. " DISPLAY_ALV OUTPUT

*&----


*

*& Form DISPLAY_ALV

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM display_alv .

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.

ENDFORM. " DISPLAY_ALV

*&----


*

*& 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 = 'BANFN'.

ls_fcat-ref_table = 'EBAN'.

APPEND ls_fcat TO p_l_fieldcat.

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 = ''.

p_s_layout-grid_title = 'create po from pr'.

p_s_layout-keyhot = ''.

ENDFORM. " PREPARE_LAYOUT

*&----


*

*& Module USER_COMMAND_0100 INPUT

*&----


*

  • text

*----


*

MODULE user_command_0100 INPUT.

CLEAR ok_code.

CASE save_ok.

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

8 REPLIES 8
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
918

It doesn't appear that you have even called the screen. You need to do that.

START-OF-SELECTION.

repid = sy-repid.

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 eban~blckd = ''
AND eban~statu = 'N'.

if sy-subrc <> 0.
message i002(zska).
endif.

CALL SCREEN 100.  "  <----- RIGHT HERE    Or whatever your screen number is.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
918

Can you tell is what you are doing with this MODULE ENDMODULE block? I don't see you calling any screen and if you are not calling any screen, then where is the call to show the ALV grid?

You need to call the screen where you defined the container for this grid.

*&----


*

*& Module DISPLAY_ALV OUTPUT

*&----


*

  • text

*----


*

MODULE display_alv OUTPUT.

PERFORM display_alv.

ENDMODULE. " DISPLAY_ALV OUTPUT

Read only

Former Member
0 Likes
918

Hi :

Even after calling the screen, still its not displaying alv .

Is there any wrong with select statement.

~Raghu

Read only

Former Member
0 Likes
918

Hi :

between module and endmodule im calling

custom container instance, alv grid instance, field catalog , field structure and

set_table_for_first_display.

Read only

0 Likes
918

It is not just enough to call the screen. In your screen PBO, are you calling this module?

Read only

Former Member
0 Likes
918

Im calling module display_alv in PBO of my screen , when i debug its going to error mssg after the select statement.

Can you give a sample prog which displays data in alv.

Read only

0 Likes
918

Check the programs listed .

What is the error that you are getting?

Read only

0 Likes
918

Make sure that you have added a custom container into the screen and that it is named correctly. The name should be 'CC_ALV'

REgards,

RIch Heilman

Message was edited by:

Rich Heilman