Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Request to check my coding..... Urgent

MY program is with ALV_Grid

1. Selection Screen

Customer Number: KUNNR

Billing Date: FKDAT

Now Using the above Selection screen inputs, I want to generate the following fields in the output.

2. Output Screen

Invoice No: VBELN

Invoice Date: FKDAT

Customer Number: KUNNR

Customer Name: NAME1

Material Description: MAKTX

Payment Terms: ZTERM

Net Value: NETWR

Ship-to City: ORT01

Sold-to party: KUNAG

Ship-to party: KUNNR

Tables Used:

Delivery: LIKP, LIPS

Invoice:VBRK, VBRP

Customer: KNA1

Material: MARA

Material Description: MAKT

Now the Problem what I got is....How to link between these tables...ie., what common fields can be used between these tables so that I can use FOR ALL ENTRIES and retrieve the above output fields.

3. Create Dictionary Structure for Output Data

4. Create Dynpro (Screen 9000)

5. Create ALV Grid Object and Call Method "set_table_for_first_display" of alv obj in PBO Module of Screen

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

this is my coding so can

&----


*& Report ZTESTALVOOPS

*&

&----


*&

*&

&----


REPORT ZTESTALVOOPS.

tables: KNA1, KNVV,VBAK,VBFA, VBRK, mara.

data gr_alv_grid type ref to cl_gui_alv_grid.

data gc_custom_control_name type scrfname value 'CC_ALV'.

data gr_custom_container type ref to cl_gui_custom_container.

data gt_fieldcat type lvc_t_fcat.

data gs_layout type lvc_s_layo.

types: lvc.

                            • selection screen *******************

select-options: so_kunnr for kna1-kunnr,

so_fkdat for vbrk-fkdat.

data begin of gt_list occurs 0.

include structure ZDIC_STRUC. " Dictionary Structure for Output Data

data end of gt_list.

                                • start of selection **********************

                                        • end of selection *************************

call screen 9000.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'SET_STATUS'.

SET TITLEBAR 'FIRST' of program prg with cnt.

perform disp_alv. " DISPLAY ALV GRID

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Form disp_alv

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM disp_alv .

if gr_alv_grid is INITIAL.

CREATE OBJECT GR_CUSTOM_CONTAINER

EXPORTING

  • PARENT =

CONTAINER_NAME = gc_custom_control_name

  • 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.

CREATE OBJECT GR_ALV_GRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = gr_custom_container

  • 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.

perform prepare_fieldcat changing gt_fieldcat.

perform prepare_layout changing gs_layout.

CALL METHOD GR_ALV_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 = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING = gt_exclude

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = gt_list[]

IT_FIELDCATALOG = gt_fieldcat

  • IT_SORT = gt_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 GR_ALV_GRID->REFRESH_TABLE_DISPLAY

  • EXPORTING

  • IS_STABLE = gt_list[]

  • I_SOFT_REFRESH = gt_list[]

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. " disp_alv

&----


*& Form prepare_fieldcat

&----


  • text

----


  • <--P_GT_FIELDCAT text

----


FORM prepare_fieldcat CHANGING P_GT_FIELDCAT type lvc_t_fcat.

data ls_fcat type lvc_s_fcat.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

I_STRUCTURE_NAME = 'dic_struc'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

  • I_INTERNAL_TABNAME =

CHANGING

CT_FIELDCAT = p_gt_fieldcat[]

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*loop at p_gt_fieldcat into ls_fcat.

*

*case ls_fcat-fieldname.

*when 'CARRID'.

*ls_fcat-hotspot = 'X'.

*ls_fcat-outputlen = '10'.

*ls_fcat-coltext = 'Carrier ID'.

*modify p_gt_fieldcat from ls_fcat.

*

*when 'PAYMENTSUM'.

*ls_fcat-no_out = 'X'.

*ls_fcat-outputlen = '10'.

*modify p_gt_fieldcat from ls_fcat.

*endcase.

*

*endloop.

ENDFORM. " prepare_fieldcat

&----


*& Form prepare_layout

&----


  • text

----


  • <--P_GS_LAYOUT text

----


FORM prepare_layout CHANGING P_GS_LAYOUT type lvc_s_layo.

p_gs_layout-zebra = 'X'.

p_gs_layout-grid_title = 'FLIGHTS'.

p_gs_layout-smalltitle = 'X'.

ENDFORM. " prepare_layout

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

case sy-ucomm.

when 'BACK'.

SET SCREEN 0.

LEAVE SCREEN.

when 'CANCEL'.

LEAVE PROGRAM.

WHEN 'OTHERS'.

LEAVE PROGRAM.

endcase.

ENDMODULE. " USER_COMMAND_0100 INPUT

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.::

Can anyone tell the code for selction statement for this program .....

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question