‎2007 Nov 06 2:34 PM
can any help me to write the coding of this report program
1. Define selection screen with KNA1-KUNNR, VBRK-FKDAT
2. Select Data from Database (with "inner join")
Tables: Customer KNA1, KNVV
SalesDocument VBAK - Head, VBAP - Positions
Invoice VBRK - Head, VBRP - Positions
Document Flow VBFA -
Invoice (VBFA_VBTYP_V = M) ->
Delivery (VBFA_VBTYP_V = J) ->
SalesOrder (VBFA-VBTYP_V = C) ->
Sales Document Data
Sales Document Partner Data VBPA (Parvw = AG, WE) - Partner Number
Customer Adress Data etc. KNA1, KNVV
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
‎2007 Nov 06 8:06 PM
Hello
You may have a look at my sample report
Using function module <b>LVC_FIELDCATALOG_MERGE</b> repetively you can easily build any kind of required fieldcatalog for your ALV output.
Have a look at the sample report <b>ZUS_SDN_REUSE_ALV_GRID_DISP</b>.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_REUSE_ALV_GRID_DISP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_reuse_alv_grid_disp.
TYPES: BEGIN OF ty_s_outtab.
TYPES: status TYPE i_status.
INCLUDE TYPE knb1.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gs_variant TYPE disvariant,
gs_layout TYPE lvc_s_layo,
gt_fcat TYPE lvc_t_fcat,
*
gs_outtab TYPE ty_s_outtab,
gt_outtab TYPE ty_t_outtab.
START-OF-SELECTION.
SELECT * FROM knb1 INTO CORRESPONDING FIELDS OF TABLE gt_outtab
WHERE bukrs = '1000'.
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
PERFORM modify_list.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = gs_layout
it_fieldcat_lvc = gt_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
i_save = 'A'
is_variant = gs_variant
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO_LVC =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_outtab
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.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
REFRESH: gt_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
" Add I_STATUS field from this structure to fieldcatalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'RIHEA'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
DELETE gt_fcat WHERE ( ref_table = 'RIHEA' AND
fieldname NE 'I_STATUS' ).
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'I_STATUS'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ls_fcat-fieldname = 'STATUS'.
INSERT ls_fcat INTO gt_fcat INDEX 1.
ENDIF.
" Renumbering of columns
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-excp_fname = 'STATUS'.
gs_layout-excp_led = 'X'. " display LED instead of lights
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'. " required for saving variants
ENDFORM. " SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
*& Form MODIFY_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM modify_list .
* define local data
DATA:
ls_outtab TYPE ty_s_outtab.
LOOP AT gt_outtab INTO ls_outtab.
" Define reasonable conditions for status
IF ( syst-tabix > 20 ).
ls_outtab-status = '3'. " = green
ELSEIF ( syst-tabix > 10 ).
ls_outtab-status = '2'. " = yellow
ELSEIF ( syst-tabix > 5 ).
ls_outtab-status = '1'. " = red
ELSE.
ls_outtab-status = '0'. " = no status
ENDIF.
MODIFY gt_outtab FROM ls_outtab.
ENDLOOP.
ENDFORM. " MODIFY_LISTRegards
Uwe
‎2007 Nov 07 2:38 AM
Hi ,
Go to the following link which gives you sample codes with brief description of the programs.
OOALV
Then coming to steps for creation of ALV in OOABAP.
1. Create a program in se38 and just activate it without any code for now.
2. Go to module pool and create a screen, put a custom container control on to the screen. (You will find this control on right side tool box).
3. Give a name to the control created in step 2.
4. Activate the screen.
5. Come to the program declare two variables to hold instances of 2 classes CL_GUI_CUSTOM_CONTAINER, CL_GUI_ALV_GRID.
6. create an instance of the class CL_GUI_CUSTOM_CONTAINER passing container name created in step 3.
7. create an instance of the class CL_GUI_ALV_GRID passing INSTANCE VARIBALE name created in step 6.
8. using the ref. variable of previous step call method SET_TABLE FORFIRST_DISPLAY method and pass structure name and internal table containing data.
9. then call screen created in step 2.
Hey... execute the program . You are there with your OOALV.
Here is the sample code.
*&---------------------------------------------------------------------*
*& Report ZGS_SIMPLE_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zgs_simple_alv.
DATA : it_mara TYPE TABLE OF mara.
DATA : container TYPE REF TO cl_gui_custom_container,
grid TYPE REF TO cl_gui_alv_grid.
SELECT * FROM mara INTO TABLE it_mara UP TO 10 ROWS.
CREATE OBJECT container
EXPORTING
* PARENT =
container_name = 'CONTAINER'
* 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 grid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = container
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
* I_FCAT_COMPLETE = SPACE
* 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.
CALL METHOD grid->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
i_structure_name = 'MARA'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
CHANGING
it_outtab = it_mara
* IT_FIELDCATALOG =
* 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.
CALL SCREEN 100.
In the same lines you can write code for any oo alv.
Reward points if useful,
Aleem.