ALV ...Logic required
Hi every body,
I have one requirement like an alv report will display
output which contains a material number.
<b>If i click On the material number it shud go to MM03...Accounting view
Logic required for this.</b>I am a beginner ...Plz help me...
Thanks in advance.
Message was edited by: raja gurrala
Hi,
See the code sample,
INCLUDE <icon>.
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid ,
o_dockingcontainer TYPE REF TO cl_gui_docking_container ,
o_eventreceiver TYPE REF TO lcl_event_receiver,
wa_layout TYPE lvc_s_layo ,
wa_variant TYPE disvariant.
CONSTANTS : c_a(1) TYPE c VALUE 'A' , " All Layouts
c_x(1) TYPE c VALUE 'X'.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
* Hot Spot Click
handle_hotspot
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id
es_row_no,
* Double Click
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no,
ENDCLASS. "lcl_event_receiver DEFINITION
* Implementation
CLASS lcl_event_receiver IMPLEMENTATION.
*& Method handle_hotspot
* This method is called when the user clicks on a hotspot to drill down.
* The following types are exported from the ALV
* LVC_S_ROW
* LVC_S_COL
* LVC_S_ROID
METHOD handle_hotspot.
* The hotspot processing coded in the form below.
PERFORM f9900_handle_hotspot USING e_row_id
e_column_id
es_row_no.
ENDMETHOD. "handle_hotspot
*& Method handle_double_click
METHOD handle_double_click.
* The double click processing should be coded in the form below.
PERFORM f9901_handle_double_click USING e_row
e_column
es_row_no.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
FORM f9900_handle_hotspot USING p_row_id
p_column_id
p_row_no.
*Read internal table for proper value.
READ TABLE i_output
INDEX p_row_id
INTO wa_output.
* Call the transaction MMBE
SET PARAMETER ID 'MAT' FIELD wa_output-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
ENDFORM. " f9900_handle_hotspot
*& Form f9901_handle_double_click
* Double Click
FORM f9901_handle_double_click USING p_row
p_column
p_row_no.
READ TABLE i_output INDEX p_row INTO wa_output.
CASE p_column.
WHEN 'MATNR'.
IF NOT wa_output-matnr IS INITIAL.
SET PARAMETER ID 'MAT' FIELD wa_output-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
ENDIF.
ENDCASE.
ENDFORM. " f9901_handle_double_click
U can use either hot spot or double click event.
If u r using hotspot set the hotspot = 'X' in fieldcatalog.
Hope this helps.
OR another method without oops concept
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
data:lv_matnr LIKE v_mmim_lc-matnr, "Material
read table i_output into w_output index rs_selfield-tabindex.
lv_matnr = w_output-matnr.
SET PARAMETER ID 'MAT' FIELD lv_matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
Clear: lv_matnr.
ENDFORM.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
<b> i_callback_user_command = 'USER_COMMAND'</b>
i_background_id = 'ALV_BACKGROUND'
IS_LAYOUT = I_LAYOUT
it_fieldcat = i_fieldcat "field catalog
I_SAVE = 'A'
IS_VARIANT = G_VARIANT
TABLES
t_outtab = i_output "output table
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.
Kindly reward points if this helps u, revert back with queries.
Message was edited by: Judith Jessie Selvi
Similar Messages
-
Logic required for Sort in ALV
Hi All,
I am dowloding the ALV report layout in excel sheet thorough mailing functionality.
I want to implenemnt the dynamic sort. Here I am writing this.but i want the logic for below code.
CALL FUNCTION 'LT_DBDATA_READ_FROM_LTDX'
EXPORTING
I_TOOL = 'LT'
IS_VARKEY = W_VARKEY_EU
TABLES
T_DBFIELDCAT = IT_DBFIELDCAT_EU
T_DBSORTINFO = IT_DBSORTINFO
T_DBFILTER = IT_FILTER_LAYOUT
T_DBLAYOUT = IT_DB_LAYOUT.
LIT_DBSORTINFO[] = IT_DBSORTINFO[].
SORT LIT_DBSORTINFO[] BY KEY1.
DELETE ADJACENT DUPLICATES FROM LIT_DBSORTINFO[] COMPARING KEY1.
LOOP AT LIT_DBSORTINFO[].
CLEAR: LW_SPOS,
LW_UP,
LW_DOWN,
LW_SUBTOT,
LW_COMP,
LW_EXPA,
LW_GROUP.
CLEAR IT_DBSORTINFO[].
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'SPOS'.
IF SY-SUBRC = 0.
LW_SPOS = IT_DBSORTINFO-VALUE.
ENDIF.
CLEAR IT_DBSORTINFO.
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'UP'.
IF SY-SUBRC = 0.
LW_UP = IT_DBSORTINFO-VALUE.
ENDIF.
CLEAR IT_DBSORTINFO.
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'DOWN'.
IF SY-SUBRC = 0.
LW_DOWN = IT_DBSORTINFO-VALUE.
ENDIF.
CLEAR IT_DBSORTINFO.
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'SUBTOT'.
IF SY-SUBRC = 0.
LW_SUBTOT = IT_DBSORTINFO-VALUE.
ENDIF.
CLEAR IT_DBSORTINFO.
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'COMP'.
IF SY-SUBRC = 0.
LW_COMP = IT_DBSORTINFO-VALUE.
ENDIF.
CLEAR IT_DBSORTINFO.
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'EXPA'.
IF SY-SUBRC = 0.
LW_EXPA = IT_DBSORTINFO-VALUE.
ENDIF.
CLEAR IT_DBSORTINFO.
READ TABLE IT_DBSORTINFO WITH KEY
KEY1 = LIT_DBSORTINFO-KEY1
PARAM = 'GROUP'.
IF SY-SUBRC = 0.
LW_GROUP = IT_DBSORTINFO-VALUE.
ENDIF.
LOOP AT IT_ALV_DATA FROM W_LOOP_FROM_EU TO W_LOOP_TO_EU.
LW_TABIX = SY-TABIX.
READ TABLE IT_FIELDCAT INTO LW_FIELDCAT WITH KEY
FIELDNAME = LIT_DBSORTINFO-KEY1.
IF SY-SUBRC = 0.
ASSIGN COMPONENT SY-TABIX OF
STRUCTURE IT_ALV_DATA TO <LFS>.
IF SY-SUBRC = 0.
CLEAR LW_CHAR.
LW_CHAR = <LFS>.
IF LW_SPOS= 'SPOS'.
LOGIC Required
ENDIF.
ELSEIF LW_OPTION = 'DOWN'.
LOgic required
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
regards,
Ajay reddyHai,
Let
1)general data
2)all customers
3)company code data
4)sales organization data
are the check box names,Then
Just use the piece of code below:
<b>IF general data = 'X'.
COUNT = COUNT + 1.
ENDIF.
IF all_customers = 'X'.
COUNT = COUNT + 1.
ENDIF.
IF company_code_data = 'X'.
COUNT = COUNT + 1.
ENDIF.
IF sales_organization_data = 'X'.
COUNT = COUNT + 1.
ENDIF.</b>
Now check whether more than one Check Boxes are selected or not
<b>IF COUNT GT 1.
"* Do the oprations what ever you want here
ENDIF.</b>
<b>Reward points if it helps you.</b>
Regds,
Rama chary.Pammi -
How to make an alv column required
Hello all,
Is there any way to make a column in an alv table required?
Thanks,
raymondHi Saravanan,
I tried your suggestion and at first I thought it should work as I als had used that solution to make fields read only or editable.
However, when I use 'SET_STATE_FIELDNAME' and fill the fields with value '00' or '01' nothing happens.
The technique works fine with 'SET_READ_ONLY_FIELDNAME'.
Any suggestion?
Regards,
Raymond -
ALV Grid, USER_COMMAND logic required.
Hi there,
In my requirement, I display ALV Grid output with check-box as first field, Material no as second field and so on. when I check checkbox and press pushbuton in application tool bar, the control leads to MM02 transaction code. How to implement this logic.
another question: suppose I check 10 checkboxes for 10 Materials and press pushbutton. 10 transaction codes (i.e. MM02) with with the Materials that I have selected comes one after another. Is it possible?
Regards,
Zakir.Hi Zakir,
Under the field catalog insert chk box logic like this
wa_fieldcat-col_pos = '1'.
wa_fieldcat-seltext_l = 'Check'.
wa_fieldcat-checkbox = 'X'.
append wa_fieldcat to it_fieldcat.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
<b> I_CALLBACK_USER_COMMAND = 'IT_USER_COMMAND'</b>* 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 = 'Purchase Order Details'
* I_GRID_SETTINGS = I_GRID_SETTINGS
is_layout = wa_layout
it_fieldcat = it_fieldcat
* IT_EXCLUDING = IT_EXCLUDING
* IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
it_sort = it_sort
* IT_FILTER = IT_FILTER
* IS_SEL_HIDE = IS_SEL_HIDE
* I_DEFAULT = 'X'
i_save = w_save
is_variant = i_variant
it_events = it_event
* IT_EVENT_EXIT = IT_EVENT_EXIT
* IS_PRINT = IS_PRINT
* IS_REPREP_ID = IS_REPREP_ID
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS = IT_ALV_GRAPHICS
* IT_HYPERLINK = IT_HYPERLINK
* IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
* IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
* IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
* ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = it_final
exceptions
program_error = 1
others = 2
*& Form IT_USER_COMMAND
* text
form it_user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
free it_fieldcat.
case r_ucomm.
when '&IC1'.
read table <final internal table>index rs_selfield-tabindex.
perform <action>.
endcase.
endform. "IT_USER_COMMAND
Thanks
Vikranth Khimavath -
Hi all iam making blocked alv programe.
In the below code if i want to display in Second block the list of Material Types with No. of materials in each type than what should be the approach for this logic.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_mara ,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
END OF ty_mara ,
BEGIN OF ty_makt ,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF ty_makt ,
BEGIN OF ty_final ,
mtart TYPE mara-mtart,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
record TYPE i ,
END OF ty_final ,
BEGIN OF records,
records TYPE i,
END OF records.
DATA no TYPE i.
*************************INTERNAL TABLES******************************
DATA: it_mara TYPE TABLE OF ty_mara ,
it_makt TYPE TABLE OF ty_makt ,
it_final TYPE TABLE OF ty_final ,
it_fieldcat TYPE slis_t_fieldcat_alv,
it_events TYPE slis_t_event ,
it_fieldcat1 TYPE slis_t_fieldcat_alv,
it_records TYPE TABLE OF records.
*************************WORK AREAS***********************************
DATA: wa_mara TYPE ty_mara ,
wa_makt TYPE ty_makt ,
wa_final TYPE ty_final ,
wa_fieldcat TYPE slis_fieldcat_alv,
wa_layout TYPE slis_layout_alv ,
wa_events TYPE slis_alv_event ,
wa_fieldcat1 TYPE slis_fieldcat_alv,
wa_records TYPE records.
**************************VARIABLES***********************************
DATA: v_mtart TYPE mara-mtart, "#EC NEEDED
v_repid TYPE sy-repid ,
v_text TYPE string .
**************************CONSTANTS***********************************
CONSTANTS: c_zrh(4) TYPE c VALUE 'zrh' ,
c_x(1) TYPE c VALUE 'X' ,
c_02(2) TYPE c VALUE '02' ,
c_04(2) TYPE c VALUE '04' ,
c_06(2) TYPE c VALUE '06' ,
c_mtart(5) TYPE c VALUE 'MTART' ,
c_matnr(5) TYPE c VALUE 'MATNR' ,
c_maktx(5) TYPE c VALUE 'MAKTX' ,
c_it_final(8) TYPE c VALUE 'IT_FINAL' ,
c_mara(4) TYPE c VALUE 'MARA' ,
c_makt(4) TYPE c VALUE 'MAKT' ,
c_l(1) TYPE c VALUE 'L' ,
c_user_command(12) TYPE c VALUE 'USER_COMMAND' ,
c_alv_user_command(16) TYPE c VALUE 'ALV_USER_COMMAND',
c_top_of_page(11) TYPE c VALUE 'TOP_OF_PAGE' ,
c_alv_top_of_page(15) TYPE c VALUE 'ALV_TOP_OF_PAGE' ,
c_end_of_list(11) TYPE c VALUE 'END_OF_LIST' ,
c_alv_end_of_list(15) TYPE c VALUE 'ALV_END_OF_LIST' .
************************INITIALIZATION********************************
INITIALIZATION.
Initialize MTART at the selection screen
PERFORM initialize_mtart.
*********************SELECTION SCREEN*********************************
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
DATA p_mtart TYPE mara-mtart.
SELECT-OPTIONS: imtart FOR p_mtart.
SELECTION-SCREEN END OF BLOCK blk1.
*********************AT SELECTION SCREEN******************************
AT SELECTION-SCREEN.
Validate MTART entered at the selection screen.
PERFORM validate_mtart.
**********************START-OF-SELECTION******************************
START-OF-SELECTION.
Select all the required data
PERFORM select_data.
Prepare final table
PERFORM populate_final_tab.
**********************END-OF-SELECTION********************************
END-OF-SELECTION.
Prepare ALV settings for display
PERFORM prepare_settings.
Display ALV Report
PERFORM display_report.
**********************SUBROUTINES*************************************
*& Form initialize_mtart
Subroutine to Initialize MTART at the selection screen.
FORM initialize_mtart .
p_mtart = c_zrh.
ENDFORM. " initialize_mtart
*& Form validate_mtart
This subroutine is to validate MTART entered at the
selection screen.
FORM validate_mtart .
SELECT SINGLE mtart
FROM t134
INTO v_mtart
WHERE mtart IN imtart.
If not found display error message
IF sy-subrc <> 0.
MESSAGE e014 WITH text-002.
ENDIF.
ENDFORM. " validate_mtart
*& Form select_data
This subroutine selects all the required data
FORM select_data .
SELECT matnr
mtart
FROM mara
INTO TABLE it_mara
WHERE mtart IN imtart.
IF sy-subrc <> 0.
MESSAGE i014 WITH text-003.
LEAVE LIST-PROCESSING.
ELSE.
SORT it_mara BY matnr.
SELECT matnr
maktx
FROM makt
INTO TABLE it_makt UP TO 20 ROWS
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr
AND spras = sy-langu .
IF sy-subrc <> 0.
MESSAGE i014 WITH text-004.
LEAVE LIST-PROCESSING.
ELSE.
SORT it_mara BY mtart.
SORT it_makt BY matnr.
ENDIF.
ENDIF.
ENDFORM. " select_data
*& Form populate_final_tab
This subroutine prepares final internal table.
FORM populate_final_tab .
LOOP AT it_mara INTO wa_mara.
CLEAR wa_final.
CLEAR wa_makt.
READ TABLE it_makt INTO wa_makt
WITH KEY matnr = wa_mara-matnr
BINARY SEARCH.
IF sy-subrc = 0.
wa_final-mtart = wa_mara-mtart.
wa_final-matnr = wa_mara-matnr.
wa_final-maktx = wa_makt-maktx.
APPEND wa_final TO it_final.
ENDIF.
ENDLOOP.
DATA : v_lines TYPE i.
DESCRIBE TABLE it_final LINES v_lines.
**WRITE:/ 'Total lines = ', v_lines.
wa_records-records = v_lines.
LOOP AT it_final INTO wa_final.
no = no + 1.
ENDLOOP.
wa_records-records = no.
APPEND wa_records TO it_records.
ENDFORM. " populate_final_tab
*& Form prepare_settings
This subroutine prepares ALV settings for display
FORM prepare_settings .
Prepare layout
CLEAR wa_layout.
wa_layout-zebra = c_x.
Prepare fieldcat
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = c_02.
wa_fieldcat-fieldname = c_mtart.
wa_fieldcat-tabname = c_it_final.
wa_fieldcat-ref_fieldname = c_mtart.
wa_fieldcat-ref_tabname = c_mara.
wa_fieldcat-ddictxt = c_l.
wa_fieldcat-seltext_l = text-005.
wa_fieldcat-seltext_m = text-005.
wa_fieldcat-seltext_s = text-005.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = c_04.
wa_fieldcat-fieldname = c_matnr.
wa_fieldcat-tabname = c_it_final.
wa_fieldcat-ref_fieldname = c_matnr.
wa_fieldcat-ref_tabname = c_mara.
wa_fieldcat-ddictxt = c_l.
wa_fieldcat-seltext_l = text-006.
wa_fieldcat-seltext_m = text-006.
wa_fieldcat-seltext_s = text-006.
wa_fieldcat-hotspot = c_x.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = c_06.
wa_fieldcat-fieldname = c_maktx.
wa_fieldcat-tabname = c_it_final.
wa_fieldcat-ref_fieldname = c_maktx.
wa_fieldcat-ref_tabname = c_makt.
wa_fieldcat-ddictxt = c_l.
wa_fieldcat-seltext_l = text-007.
wa_fieldcat-seltext_m = text-007.
wa_fieldcat-seltext_s = text-007.
APPEND wa_fieldcat TO it_fieldcat.
records field cat
wa_fieldcat1-col_pos = c_04.
wa_fieldcat1-fieldname = 'RECORDS'.
wa_fieldcat1-tabname = 'RECORDS'.
wa_fieldcat1-seltext_m = 'NO OF RECORDS MATERIAL WISE TYPE LIST'.
APPEND wa_fieldcat1 TO it_fieldcat1.
Prepare Events table.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events
EXCEPTIONS
list_type_wrong = 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.
SORT it_events BY name.
CLEAR wa_events.
READ TABLE it_events INTO wa_events
WITH KEY name = c_user_command
BINARY SEARCH.
IF sy-subrc = 0.
wa_events-form = c_alv_user_command.
MODIFY it_events
FROM wa_events
INDEX sy-tabix
TRANSPORTING form.
ENDIF.
CLEAR wa_events.
READ TABLE it_events INTO wa_events
WITH KEY name = c_top_of_page
BINARY SEARCH.
IF sy-subrc = 0.
wa_events-form = c_alv_top_of_page.
MODIFY it_events
FROM wa_events
INDEX sy-tabix
TRANSPORTING form.
ENDIF.
CLEAR wa_events.
READ TABLE it_events INTO wa_events
WITH KEY name = c_end_of_list
BINARY SEARCH.
IF sy-subrc = 0.
wa_events-form = c_alv_end_of_list.
MODIFY it_events
FROM wa_events
INDEX sy-tabix
TRANSPORTING form.
ENDIF.
ENDFORM. " prepare_settings
*& Form display_report
This subroutine calls FM to display report
FORM display_report .
CLEAR v_repid.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat
i_tabname = 'it_FINAL'
it_events = it_events
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = it_final
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 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.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat1
i_tabname = 'TY_FINAL'
it_events = it_events
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = it_records
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 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.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
IS_PRINT = it_final
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
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. " display_report
*& Form alv_user_command
This subroutine handles user command
FORM alv_user_command USING v_cmd TYPE sy-ucomm
wa_selfield TYPE slis_selfield. "#EC * "#EC
CLEAR wa_final.
READ TABLE it_final INTO wa_final
INDEX wa_selfield-tabindex.
CLEAR v_text.
CONCATENATE text-008
wa_final-matnr
INTO v_text
SEPARATED BY space.
Display to user which material he/she has clicked
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
titel = text-009
textline1 = v_text
start_column = 25
start_row = 6.
ENDFORM. "alv_user_command.
*& Form alv_top_of_page
This subroutine writes top of page
FORM alv_top_of_page. "#EC CALLED
FORMAT COLOR COL_HEADING.
ULINE AT /1(80).
WRITE:/1 sy-vline,
2 text-010,
9 sy-datum,
80 sy-vline.
WRITE:/1 sy-vline,
2 text-011,
9 sy-uzeit,
40 text-012,
80 sy-vline.
WRITE:/1 sy-vline,
2 text-013,
9 sy-uname,
80 sy-vline.
ULINE AT /1(80).
FORMAT COLOR OFF.
ENDFORM. "alv_top_of_page.
*& Form alv_end_of_list
This subroutine writes end of list
FORM alv_end_of_list. "#EC CALLED
FORMAT COLOR COL_HEADING.
ULINE AT /1(80).
WRITE:/1 sy-vline,
2 text-014,
12 no,
80 sy-vline.
ULINE AT /1(80).
FORMAT COLOR OFF.
ENDFORM. "alv_end_of_list.hi,
here it is.
*& Report ZTEST_DS
REPORT ztest_ds.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_mara ,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
END OF ty_mara ,
BEGIN OF ty_makt ,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF ty_makt ,
BEGIN OF ty_final ,
mtart TYPE mara-mtart,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
record TYPE i ,
END OF ty_final ,
BEGIN OF records,
records TYPE i,
END OF records.
DATA no TYPE i.
*************************INTERNAL TABLES******************************
DATA : it_mara TYPE TABLE OF ty_mara ,
it_makt TYPE TABLE OF ty_makt ,
it_final TYPE TABLE OF ty_final ,
it_fieldcat TYPE slis_t_fieldcat_alv,
it_events TYPE slis_t_event ,
it_fieldcat1 TYPE slis_t_fieldcat_alv,
it_records TYPE TABLE OF records WITH HEADER LINE.
*************************WORK AREAS***********************************
DATA : wa_mara TYPE ty_mara ,
wa_makt TYPE ty_makt ,
wa_final TYPE ty_final ,
wa_fieldcat TYPE slis_fieldcat_alv,
wa_layout TYPE slis_layout_alv ,
wa_events TYPE slis_alv_event ,
wa_fieldcat1 TYPE slis_fieldcat_alv,
wa_records TYPE records.
**************************VARIABLES***********************************
DATA : v_mtart TYPE mara-mtart, "#EC NEEDED
v_repid TYPE sy-repid ,
v_text TYPE string .
<b>DATA : BEGIN OF i_rec OCCURS 0,
mtart TYPE mara-mtart,
record TYPE i,
END OF i_rec.
DATA : BEGIN OF i_rec_col OCCURS 0,
mtart TYPE mara-mtart,
record TYPE i,
END OF i_rec_col.</b>
**************************CONSTANTS***********************************
CONSTANTS : c_zrh(4) TYPE c VALUE 'zrh' ,
c_x(1) TYPE c VALUE 'X' ,
c_02(2) TYPE c VALUE '02' ,
c_04(2) TYPE c VALUE '04' ,
c_06(2) TYPE c VALUE '06' ,
c_mtart(5) TYPE c VALUE 'MTART' ,
c_matnr(5) TYPE c VALUE 'MATNR' ,
c_maktx(5) TYPE c VALUE 'MAKTX' ,
c_it_final(8) TYPE c VALUE 'IT_FINAL' ,
c_mara(4) TYPE c VALUE 'MARA' ,
c_makt(4) TYPE c VALUE 'MAKT' ,
c_l(1) TYPE c VALUE 'L' ,
c_user_command(12) TYPE c VALUE 'USER_COMMAND' ,
c_alv_user_command(16) TYPE c VALUE 'ALV_USER_COMMAND',
c_top_of_page(11) TYPE c VALUE 'TOP_OF_PAGE' ,
c_alv_top_of_page(15) TYPE c VALUE 'ALV_TOP_OF_PAGE' ,
c_end_of_list(11) TYPE c VALUE 'END_OF_LIST' ,
c_alv_end_of_list(15) TYPE c VALUE 'ALV_END_OF_LIST' .
************************INITIALIZATION********************************
INITIALIZATION.
Initialize MTART at the selection screen
PERFORM initialize_mtart.
*********************SELECTION SCREEN*********************************
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
DATA p_mtart TYPE mara-mtart.
SELECT-OPTIONS: imtart FOR p_mtart.
SELECTION-SCREEN END OF BLOCK blk1.
*********************AT SELECTION SCREEN******************************
AT SELECTION-SCREEN.
Validate MTART entered at the selection screen.
PERFORM validate_mtart.
**********************START-OF-SELECTION******************************
START-OF-SELECTION.
Select all the required data
PERFORM select_data.
Prepare final table
PERFORM populate_final_tab.
**********************END-OF-SELECTION********************************
END-OF-SELECTION.
Prepare ALV settings for display
PERFORM prepare_settings.
Display ALV Report
PERFORM display_report.
**********************SUBROUTINES*************************************
*& Form initialize_mtart
Subroutine to Initialize MTART at the selection screen.
FORM initialize_mtart .
p_mtart = c_zrh.
ENDFORM. " initialize_mtart
*& Form validate_mtart
This subroutine is to validate MTART entered at the
selection screen.
FORM validate_mtart .
SELECT SINGLE mtart
FROM t134
INTO v_mtart
WHERE mtart = p_mtart.
If not found display error message
IF sy-subrc <> 0.
MESSAGE e014 WITH text-002.
ENDIF.
ENDFORM. " validate_mtart
*& Form select_data
This subroutine selects all the required data
FORM select_data .
SELECT matnr
mtart
FROM mara
INTO TABLE it_mara
WHERE mtart IN imtart.
IF sy-subrc <> 0.
MESSAGE i014 WITH text-003.
LEAVE LIST-PROCESSING.
ELSE.
SORT it_mara BY matnr.
SELECT matnr
maktx
FROM makt
INTO TABLE it_makt UP TO 20 ROWS
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr
AND spras = sy-langu .
IF sy-subrc <> 0.
MESSAGE i014 WITH text-004.
LEAVE LIST-PROCESSING.
ELSE.
SORT it_mara BY mtart.
SORT it_makt BY matnr.
ENDIF.
ENDIF.
ENDFORM. " select_data
*& Form populate_final_tab
This subroutine prepares final internal table.
FORM populate_final_tab .
LOOP AT it_mara INTO wa_mara.
CLEAR wa_final.
CLEAR wa_makt.
READ TABLE it_makt INTO wa_makt
WITH KEY matnr = wa_mara-matnr
BINARY SEARCH.
IF sy-subrc = 0.
wa_final-mtart = wa_mara-mtart.
wa_final-matnr = wa_mara-matnr.
wa_final-maktx = wa_makt-maktx.
APPEND wa_final TO it_final.
ENDIF.
ENDLOOP.
LOOP AT it_final INTO wa_final.
no = no + 1.
ENDLOOP.
wa_records-records = no.
it_records-records = no.
APPEND it_records.
<b> LOOP AT it_final INTO wa_final.
i_rec-mtart = wa_final-mtart.
i_rec-record = 1.
APPEND i_rec.
ENDLOOP.
LOOP AT i_rec.
MOVE-CORRESPONDING i_rec TO i_rec_col.
COLLECT i_rec_col.
ENDLOOP.</b>
ENDFORM. " populate_final_tab
*& Form prepare_settings
This subroutine prepares ALV settings for display
FORM prepare_settings .
Prepare layout
CLEAR wa_layout.
wa_layout-zebra = c_x.
Prepare fieldcat
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = c_02.
wa_fieldcat-fieldname = c_mtart.
wa_fieldcat-tabname = c_it_final.
wa_fieldcat-ref_fieldname = c_mtart.
wa_fieldcat-ref_tabname = c_mara.
wa_fieldcat-ddictxt = c_l.
wa_fieldcat-seltext_l = text-005.
wa_fieldcat-seltext_m = text-005.
wa_fieldcat-seltext_s = text-005.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = c_04.
wa_fieldcat-fieldname = c_matnr.
wa_fieldcat-tabname = c_it_final.
wa_fieldcat-ref_fieldname = c_matnr.
wa_fieldcat-ref_tabname = c_mara.
wa_fieldcat-ddictxt = c_l.
wa_fieldcat-seltext_l = text-006.
wa_fieldcat-seltext_m = text-006.
wa_fieldcat-seltext_s = text-006.
wa_fieldcat-hotspot = c_x.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = c_06.
wa_fieldcat-fieldname = c_maktx.
wa_fieldcat-tabname = c_it_final.
wa_fieldcat-ref_fieldname = c_maktx.
wa_fieldcat-ref_tabname = c_makt.
wa_fieldcat-ddictxt = c_l.
wa_fieldcat-seltext_l = text-007.
wa_fieldcat-seltext_m = text-007.
wa_fieldcat-seltext_s = text-007.
APPEND wa_fieldcat TO it_fieldcat.
<b>wa_fieldcat1-col_pos = c_04.
wa_fieldcat1-fieldname = 'MTART'.
wa_fieldcat1-tabname = 'I_REC_COL'.
wa_fieldcat1-seltext_m = 'Material Type'.
APPEND wa_fieldcat1 TO it_fieldcat1.
records field cat
wa_fieldcat1-col_pos = c_04.
wa_fieldcat1-fieldname = 'RECORD'.
wa_fieldcat1-tabname = 'I_REC_COL'.
wa_fieldcat1-seltext_m = 'NO OF RECORDS MATERIAL WISE TYPE LIST'.
APPEND wa_fieldcat1 TO it_fieldcat1.</b>*
Prepare Events table.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events
EXCEPTIONS
list_type_wrong = 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.
SORT it_events BY name.
CLEAR wa_events.
READ TABLE it_events INTO wa_events
WITH KEY name = c_user_command
BINARY SEARCH.
IF sy-subrc = 0.
wa_events-form = c_alv_user_command.
MODIFY it_events
FROM wa_events
INDEX sy-tabix
TRANSPORTING form.
ENDIF.
CLEAR wa_events.
READ TABLE it_events INTO wa_events
WITH KEY name = c_top_of_page
BINARY SEARCH.
IF sy-subrc = 0.
wa_events-form = c_alv_top_of_page.
MODIFY it_events
FROM wa_events
INDEX sy-tabix
TRANSPORTING form.
ENDIF.
CLEAR wa_events.
READ TABLE it_events INTO wa_events
WITH KEY name = c_end_of_list
BINARY SEARCH.
IF sy-subrc = 0.
wa_events-form = c_alv_end_of_list.
MODIFY it_events
FROM wa_events
INDEX sy-tabix
TRANSPORTING form.
ENDIF.
ENDFORM. " prepare_settings
*& Form display_report
This subroutine calls FM to display report
FORM display_report .
CLEAR v_repid.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat
i_tabname = 'it_FINAL'
it_events = it_events
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = it_final
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 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.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat1
i_tabname = 'TY_FINAL'
it_events = it_events
IT_SORT =
I_TEXT = ' '
TABLES
<b> t_outtab = i_rec_col</b>
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 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.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
IS_PRINT = it_final
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
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. " display_report
*& Form alv_user_command
This subroutine handles user command
FORM alv_user_command USING v_cmd TYPE sy-ucomm
wa_selfield TYPE slis_selfield. "#EC * "#EC
CLEAR wa_final.
READ TABLE it_final INTO wa_final
INDEX wa_selfield-tabindex.
CLEAR v_text.
CONCATENATE text-008
wa_final-matnr
INTO v_text
SEPARATED BY space.
Display to user which material he/she has clicked
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
titel = text-009
textline1 = v_text
start_column = 25
start_row = 6.
ENDFORM. "alv_user_command.
*& Form alv_top_of_page
This subroutine writes top of page
FORM alv_top_of_page. "#EC CALLED
FORMAT COLOR COL_HEADING.
ULINE AT /1(80).
WRITE:/1 sy-vline,
2 text-010,
9 sy-datum,
80 sy-vline.
WRITE:/1 sy-vline,
2 text-011,
9 sy-uzeit,
40 text-012,
80 sy-vline.
WRITE:/1 sy-vline,
2 text-013,
9 sy-uname,
80 sy-vline.
ULINE AT /1(80).
FORMAT COLOR OFF.
ENDFORM. "alv_top_of_page.
it will solve ur problem.
reward if useful. -
Hi All,
Pl find the requirement below.
We have a inventory report in that we were showing the stock as on date and the value of that stock.
This inventory data ( Stock Only) will come from AFS( SAP System) as well as Non-SAP System.To calculate the stock value we are capturing the Moving avarage value from MBEW Table ( Data Source : 0MAT_PLANT_ATTR).It's kf so i have added KF in the 0MAT_PLANT and directly i was inserting this in Query level and doing caluclation.
Issue : In MBEW Table level moving average price will be maintained at material level and it will contain only the latest price.Means If moving price changes several times in MBEW table it will contain latest one and it will be updated the same in BI also.When i am calculating the inventory for back months it will take the new price and stock value will come .This should not happen.
Ex :
Material Month Stock Moving avarage Price Value
A jUL'10 10 120 /- 10*120
B SEP'10 10 150 10*150
As per the above example if i run report in Jul'10 value will come as 1200 after two months i will go back and check the value of stock for Jul'2010 will be 1500.But actually it was 1200.
Solution : As informed by FS-Consultants there is one more table MBEWH contains historic information moving avarage prise based on period and month.But when i have chaked there is no standard extractorbased on MBEWH and how can i include in the reporting(How to impliment the logic).
Regards
Ramakanth.Hi All,
Pl find the requirement below.
We have a inventory report in that we were showing the stock as on date and the value of that stock.
This inventory data ( Stock Only) will come from AFS( SAP System) as well as Non-SAP System.To calculate the stock value we are capturing the Moving avarage value from MBEW Table ( Data Source : 0MAT_PLANT_ATTR).It's kf so i have added KF in the 0MAT_PLANT and directly i was inserting this in Query level and doing caluclation.
Issue : In MBEW Table level moving average price will be maintained at material level and it will contain only the latest price.Means If moving price changes several times in MBEW table it will contain latest one and it will be updated the same in BI also.When i am calculating the inventory for back months it will take the new price and stock value will come .This should not happen.
Ex :
Material Month Stock Moving avarage Price Value
A jUL'10 10 120 /- 10*120
B SEP'10 10 150 10*150
As per the above example if i run report in Jul'10 value will come as 1200 after two months i will go back and check the value of stock for Jul'2010 will be 1500.But actually it was 1200.
Solution : As informed by FS-Consultants there is one more table MBEWH contains historic information moving avarage prise based on period and month.But when i have chaked there is no standard extractorbased on MBEWH and how can i include in the reporting(How to impliment the logic).
Regards
Ramakanth. -
hi experts,
well i am having a problem regarding ALV display...the requirement is :
ALV DISPLAY SHOULD BE LIKE THIS
Open Balance 12345
SY-DATUM POSTING DATE DOC. NUMBER LOCAL CURRENCY AMOUNT
now the sum of the amount is displayed in front of open balance field, which is displayed in a first row of ALV display. And below are the columns with heading are having a details of the GL-ACCOUNT.
Is this possible using a same ALV grid display or i have to use 2 ALV grid display? In both cases plz let me know to get this sort of output?
regards,
Yahya Shoaib.In the heading part you can display the total..
*& Report ZTRN_ALV1
REPORT ZTRN_ALV1.
TYPE-POOLS: SLIS.
DATA: REPID LIKE SY-REPID,
FCAT TYPE SLIS_T_FIELDCAT_ALV,
GCAT TYPE SLIS_FIELDCAT_ALV,
FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
GCAT1 TYPE SLIS_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV,
T_EVENTS TYPE SLIS_T_EVENT,
EVENTS TYPE SLIS_ALV_EVENT,
HEADING TYPE SLIS_T_LISTHEADER,
HEADER TYPE SLIS_LISTHEADER.
PARAMETERS: CCODE LIKE LFB1-BUKRS.
DATA: BEGIN OF ITAB OCCURS 0,
lifnr LIKE LFA1-LIFNR,
BUKRS LIKE LFB1-BUKRS,
NAME1 LIKE LFA1-NAME1,
END OF ITAB.
DATA: BEGIN OF JTAB OCCURS 0,
EBELN LIKE EKKO-EBELN,
lifnr LIKE LFA1-LIFNR,
AEDAT LIKE EKKO-AEDAT,
END OF JTAB.
*DATA: JTAB LIKE STANDARD TABLE OF EKKO WITH HEADER LINE INITIAL SIZE 0.
START-OF-SELECTION.
REPID = SY-REPID.
PERFORM FETCH.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM GET_EVENTS.
PERFORM EVENTS.
PERFORM OUTPUT.
*& Form FETCH
text
--> p1 text
<-- p2 text
FORM FETCH .
SELECT ALIFNR ANAME1 BBUKRS INTO CORRESPONDING FIELDS OF TABLE ITAB FROM LFA1 AS A JOIN LFB1 AS B ON ALIFNR EQ B~LIFNR WHERE
B~BUKRS EQ CCODE.
ENDFORM. " FETCH
*& Form FIELDCAT
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
GCAT-COL_POS = '1'.
GCAT-FIELDNAME = 'BUKRS'.
GCAT-TABNAME = ITAB.
GCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND GCAT TO FCAT.
GCAT-COL_POS = '2'.
GCAT-FIELDNAME = 'LIFNR'.
GCAT-TABNAME = ITAB.
GCAT-SELTEXT_M = 'VENDOR NUMBER'.
APPEND GCAT TO FCAT.
GCAT-COL_POS = '3'.
GCAT-FIELDNAME = 'NAME1'.
GCAT-TABNAME = ITAB.
GCAT-SELTEXT_M = 'VENDOR NAME'.
APPEND GCAT TO FCAT.
ENDFORM. " FIELDCAT
*& Form LAYOUT
text
--> p1 text
<-- p2 text
FORM LAYOUT .
LAYOUT-ZEBRA = 'X'.
ENDFORM. " LAYOUT
*& Form GET_EVENTS
text
--> p1 text
<-- p2 text
FORM GET_EVENTS .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = T_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. " GET_EVENTS
*& Form EVENTS
text
--> p1 text
<-- p2 text
FORM EVENTS .
READ TABLE T_EVENTS INTO EVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
EVENTS-FORM = 'TOP_OF_PAGE'.
MODIFY TABLE T_EVENTS FROM EVENTS TRANSPORTING FORM.
READ TABLE T_EVENTS INTO EVENTS WITH KEY NAME = 'USER_COMMAND'.
EVENTS-FORM = 'USER_COMMAND'.
MODIFY TABLE T_EVENTS FROM EVENTS TRANSPORTING FORM.
ENDFORM. " EVENTS
*& Form OUTPUT
text
--> p1 text
<-- p2 text
FORM OUTPUT .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_TOP_OF_PAGE = '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 = LAYOUT
IT_FIELDCAT = FCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
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. " OUTPUT
*& Form TOP_OF_PAGE
text
--> p1 text
<-- p2 text
FORM TOP_OF_PAGE .
CLEAR HEADING[]. <----IN THIS INTERNAL TABLE YOU EASILY DISPLAY TOTAL...
HEADER-TYP = 'H'.
HEADER-INFO = 'WIPRO TECHNOLOGIES'.
APPEND HEADER TO HEADING.
HEADER-TYP = 'S'.
HEADER-INFO = 'ADVANCED ABAP TRAINING'.
APPEND HEADER TO HEADING.
HEADER-TYP = 'A'.
HEADER-INFO = 'LIST OF VENDORS'.
APPEND HEADER TO HEADING.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING[]
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM. -
Logic required to findout "Release To Date" of the Purchase order
Hi
We are developing a custom program to release purchase orders as per clients requirements. In that, in the output, we need to display the "Release To Date" of the purchase order. Consider the release codes are R1,R2& R3, and currently the PO is released by R1, then we need to show "Release To Date" as R1. Simillerly once R2 also released the PO, we need to show "R1 R2" in the Release To Date field. This you can see in the Release Tab of the PO.
Now we need to adopt the same logic in our custom program also. Which table i can find the release to date details. The latest release code of the PO also good enough to build the logic to findout the "Release To Date"
Any pointers would be of great help.
Thanks
Venkat.Hi Venkat,
Check up these tables
T16FC, T16FD, T16FG, V_T16FC
Regards,
Hareesha
If it's help's reward the pts -
Hi all,
I have requirement saying that transfer data from one program to another transaction selection screen.
Requirement is.
In a programi will l have final data in one internal table.
This data i need to send it for another program selection screen as input.
Please provide me the logic.
Thanks in advanceuse the first program as an include for the second program
then in the intilisation of the second program
use the values of the internal table of 1st program.
regards,
srinivas
<b>*reward for useful answers*</b> -
Hi All,
I require to download the ALV output in excel format using the export button in the toolbar. Can anyone please tell the process how to implement this functionality.
Regards,
MainakHi,
I have written the below code in WDDOINIT of the main view to enable export functionality. Please suggest if there is any other way.
DATA:
lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
DATA:
lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
DATA: lr_export_settings TYPE REF TO if_salv_wd_export_settings,
r_table type ref to CL_SALV_WD_CONFIG_TABLE,
lr_std_func TYPE REF TO if_salv_wd_std_functions.
lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
lr_salv_wd_table_usage->create_component( ).
ENDIF.
*... get ALV component
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
*... (1) get ConfigurationModel from ALV Component
wd_this->r_table = lr_salv_wd_table->get_model( ).
*... init FunctionSettings
cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
r_model = wd_this->r_table ).
lr_std_func ?= wd_this->r_table.
lr_std_func->set_export_allowed( abap_true ). -
Programming Logic required for pulling the records for past month /week
Hi All
I need help in the SQL programming logic.
Oracle Database Version: 10.2.0.3.0
Requirement
In a data warehouse environment, I need to programme for weekly and monthly automated batch jobs to insert the data from Data_tbl to Reporting_tbl for generating reports. Tables descriptions are given below.
Table1 - Data_tbl (Source table –this table gets updated everyday).
Record_dt first_name last_name
Table2 - Reporting_tbl_(Target table)
Cycle_dt first_name last_name
1. Monthly Report
In the SQL Query, I have where clause condition—
Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’
Using the above condition in development, I am pulling the data from source table for the past month data. This will be repeated every month and it should be automated.
i.e., if I run this report any time in dec 2008, it should pick records of dates from Nov 01st to Nov 30th 2008. if I run this report any time in Jan 2009, it should pick records of dates from Dec 01st to Dec 31st 2008.
Date Values should be assigned for past month. Value of Cycle_dt in target table should be end date of past month like 30-nov-2008, 31-dec-2008.
2. Weekly Report
In the SQL Query, I have where clause condition—
Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’
Here week start day is Monday and end day is Sunday.
If I run the report between Dec 08th to Dec 14th , it should pull records of dates from Dec 01st to Dec 07th 2008.
On Dec 15th, it should pick from Dec 08th to Dec 14th.
Value of Cycle_dt in target table should be end date of past week like 07-Dec-2008, 14-Dec-2008.
Please help me with the logics for both Monthly and Weekly reports.
ThanksHi,
For the monthly report, instead of
Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’say:
Where Record_dt >= TRUNC (ADD_MONTHS (SYSDATE, -1), 'MM')
and record_dt < TRUNC (SYSDATE, 'MM')SYSDATE is the current DATE.
TRUNC (SYSDATE, 'MM') is the beginning of the current month. (Notice the condition above is less than this date, not equal to it.)
ADD_MONTHS (STSDATE, -1) is a date exactly one month ago, therefore it is in the previous month.
For the weekly report, instead of:
Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’say
Where Record_dt >= TRUNC (SYSDATE - 7, 'IW')
and record_dt < TRUNC (SYSDATE, 'IW')TRUNC (dt, 'IW') is the beginning of the ISO week (Monday-Sunday) that contains dt. Again, notice the end condition is strictly less than the beginning of the current week. -
Logic Required in HR ABAP Program
Hi,
First i have to check the Change Date on Infotype 0000 Actions infotype (P0000-AEDTM). If the change date falls within the Period Selection date specified then i have to include the employee in the report.
the included fields are:
P0000-AEDTM,P0001-BUKRS,PERNR,ENAME,P0000-MASSN,P0000-MASSG,P0000-BEGDA,P0001-ORGEH,P0001-PLANS,P0001-STELLP0001-ABKRS,P0001-WERKS,P0001-BTRTL,Q0001-MSTBR,Q0001-ENAME(supervisor name)
If the change date (P0000-AEDTM) does not fall within the Period Selection Date, i have to check the Change Date in Infotype 0001 Organization Assignment infotype (P0001-AEDTM). If the change date falls within the Period Selection date specified then i have to include the employee in the report. Include in report only that information which has been changed from the previous Infotype 0001 record, except for Change Date, Company Code, Personnel Number and Name, which must always be included in the report.
For this requirement i have written the below code:
LOOP AT p0000 WHERE aedtm >= pn-begda AND
aedtm <= pn-endda.
wa_final-massn = p0000-massn.
wa_final-pernr = p0000-pernr.
wa_final-aedtm = p0000-aedtm.
wa_final-massg = p0000-massg.
wa_final-begda = p0000-begda.
wa_final-begda = p0000-begda.
rp-provide-from-last p0001 space p0000-begda p0000-endda.
wa_final-bukrs = p0001-bukrs.
wa_final-kostl = p0001-kostl.
wa_final-mstbr = p0001-mstbr.
wa_final-ename = p0001-ename.
APPEND wa_final TO it_final.
CLEAR wa_final.
ENDLOOP.
if sy-subrc ne 0.
LOOP AT p0001 WHERE aedtm >= pn-begda AND
aedtm <= pn-endda.
lv_endda = p0001-begda - 1.
READ TABLE p0001 WITH KEY pernr = p0001-pernr endda = lv_endda INTO w0001.
IF sy-subrc = 0.
if p0001-kostl ne w0001-kostl.
wa_final-kostl = p0001-kostl.
endif.
if p0001-mstbr ne w0001-mstbr.
wa_final-mstbr = p0001-mstbr.
endif.
wa_final-pernr = p0001-pernr.
wa_final-aedtm = p0001-aedtm.
wa_final-bukrs = p0001-bukrs.
wa_final-ename = p0001-ename.
APPEND wa_final TO it_final.
CLEAR wa_final.
Endif.
Endif..
is this code correct? or do i have to do any modifications?This is like retro payroll run see the payroll program.
RPCUCALC00 and you will find the logic over there how it will run retroactive payroll
Best Regards -
Tables Proration/Spliting Logic required
Hi Friends
I have 3 internal tables:
IT_0001:
PERNR BEGDA ENDDA WERKS BTRTL ABKRS KOSTL ORGEH
10774 20080101 20081028 US11 14 CB 0
10774 20081029 99991231 US11 14 CB 1125100 30084829
IT_0008_1:
PERNR BEGDA ENDDA TRFGR BAND1
10774 20080101 20080803 1 1
IT_0008:
PERNR BEGDA ENDDA TRFST BAND
10774 20080804 20081231 6 6
WITH THE ABOVE TABLES COMBINATION,BY SPLITING THE TABLES BASED ON BEGDA,ENDDA
MY FINAL TABLE HAS TO COME AS FOLLOWS:
IT_FINAL:
PERNR BEGDA ENDDA WERKS BTRTL MOLGA BAND BONUSPRCNTAGE
10774 20080101 20080803 US11 14 10 1 8
10774 20080804 20081028 US11 14 10 6 8
10774 20081029 20081231 US11 14 10 6 8
Can any one please provide me the logic for this.
Thanks for your cooperation.
Regards,
SreeHi Gourav
Thanks for your suggestion!
Let me ask the same question in this way then:
Please correct me the code where I am wrong:
Logic for Proration calculation for Bonus Percentage when Band
maintained in TRFGR field.
SORT it_0001_1 BY pernr begda endda.
SORT it_0008_1 BY pernr begda endda.
LOOP AT it_0001_1 INTO wa_0001_1.
LOOP AT it_0008_1 INTO wa_0008_1 WHERE pernr = wa_0001_1-pernr.
To check the end date is 12/31/9999, if yes then set it to bonus year end date
IF wa_0008_1-endda = c_year OR wa_0008_1-endda0(4) > gv_endyear0(4).
wa_0008_1-endda = c_aug_e.
MODIFY it_0008_1 FROM wa_0008_1 TRANSPORTING endda.
ELSEIF wa_0001_1-endda = c_year.
wa_0001_1-endda = gv_endyear.
ENDIF.
***Condition to split the records based on the records in PA0001 and Pa0008 tables data
IF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda = wa_0008_1-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0001_1-begda.
wa_final-endda = wa_0001_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
EXIT.
ELSEIF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda > wa_0008_1-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0001_1-begda.
wa_final-endda = wa_0008_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_final-begda < wa_final-endda.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
gv_date = wa_0008_1-endda.
IF ( gv_date+4(4) EQ c_leap ). " to check date is feb 28th
gv_mod = wa_0008_1-endda+0(4) MOD 4.
gv_mod1 = wa_0008_1-endda+0(4) MOD 4.
IF ( gv_mod EQ 0 OR gv_mod1 EQ 0 ). " to check for leap year
wa_0008_1-endda+4(4) = c_leap1.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0008_1-endda.
wa_final-endda = wa_0001_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
EXIT.
ELSEIF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda < wa_0008_1-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0001_1-begda.
wa_final-endda = wa_0001_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_final-begda < wa_final-endda.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
gv_date = wa_0008_1-endda.
IF ( gv_date+4(4) EQ c_leap ). " to check date is feb 29th
gv_mod = wa_0008_1-endda+0(4) MOD 4.
gv_mod1 = wa_0008_1-endda+0(4) MOD 4.
IF ( gv_mod EQ 0 OR gv_mod1 EQ 0 ). " to check for leap year
wa_0008_1-endda+4(4) = c_leap1.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0008_1-endda.
wa_final-endda = wa_0001_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
ENDIF.
ELSEIF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda >= wa_0008_1-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0001_1-endda + 1.
wa_final-endda = wa_0008_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
ENDIF.
ENDIF.
EXIT.
ENDIF.
CLEAR: wa_0008_1,
gv_date.
ENDLOOP.
***** 23/07/2008
LOOP AT it_0008 INTO wa_0008 WHERE pernr = wa_0001_1-pernr.
To check the end date is 12/31/9999, if yes then set it to bonus year end date
IF wa_0008-endda = c_year OR wa_0008-endda0(4) > c_end0(4).
wa_0008-endda = c_end.
MODIFY it_0008 FROM wa_0008 TRANSPORTING endda.
ELSEIF wa_0001_1-endda = c_year.
wa_0001_1-endda = c_end.
ENDIF.
***Condition to split the records based on the records in PA0001 and Pa0008 tables data
IF wa_0001_1-begda <= wa_0008-begda AND wa_0001_1-endda = wa_0008-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0008-begda. "CHANGED FROM 0001 TO 0008
wa_final-endda = wa_0008-endda. "CHANGED FROM 0001 TO 0008
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
EXIT.
ELSEIF wa_0001_1-begda <= wa_0008-begda AND wa_0001_1-endda > wa_0008-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0008-begda. "look here
wa_final-endda = wa_0008-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_final-begda < wa_final-endda.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
ENDIF.
ELSEIF wa_0001_1-begda <= wa_0008-begda AND wa_0001_1-endda < wa_0008-endda.
wa_final-pernr = wa_0001_1-pernr.
wa_final-begda = wa_0008-begda.
wa_final-endda = wa_0001_1-endda.
wa_final-werks = wa_0001_1-werks.
wa_final-btrtl = wa_0001_1-btrtl.
wa_final-kostl = wa_0001_1-kostl.
IF wa_final-begda < wa_final-endda.
IF wa_0001_1-kostl IS NOT INITIAL.
APPEND wa_final TO it_final.
ELSE.
APPEND wa_final TO it_costcenter.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
****23/07/2007
ENDLOOP.
***Updating the IT_0001_1 and IT_COSTCENTER tables with band information.
IF it_final[] IS NOT INITIAL.
LOOP AT it_final INTO wa_final.
gv_tabix = sy-tabix.
LOOP AT it_0008_1 INTO wa_0008_1 WHERE pernr EQ wa_final-pernr
AND begda LE wa_final-begda
AND endda GE wa_final-endda.
READ TABLE it_cgroup INTO wa_cgroup WITH KEY werks = wa_final-werks
btrtl = wa_final-btrtl.
IF sy-subrc EQ 0.
wa_final-band = wa_0008_1-trfgr.
wa_final-molga = wa_cgroup-molga.
MODIFY it_final FROM wa_final INDEX gv_tabix TRANSPORTING band molga.
CLEAR: wa_0008_1,
wa_final,
gv_tabix.
ENDIF.
ENDLOOP.
***TRFST CALCULATION.
LOOP AT it_0008 INTO wa_0008 WHERE pernr EQ wa_final-pernr
AND begda LE wa_final-begda
AND endda GE wa_final-endda.
READ TABLE it_cgroup INTO wa_cgroup WITH KEY werks = wa_final-werks
btrtl = wa_final-btrtl.
IF sy-subrc EQ 0.
wa_final-band = wa_0008-trfst.
wa_final-molga = wa_cgroup-molga.
MODIFY it_final FROM wa_final INDEX gv_tabix TRANSPORTING band molga.
CLEAR: wa_0008,
wa_final,
gv_tabix.
ENDIF.
ENDLOOP.
CLEAR: wa_final.
ENDLOOP.
ENDIF.
Actually I have developed code but it's not giving the required results.
That's why I asked for the solution .My intension in asking the solution is to get various types of approaches of the solution but not to waste the comunity time.
Anyhow thanks!
Regards,
Sree -
Sample ALV report required for FI module
Hello friends,
I am develoing ALV report for FI module for that i need some sample ALV report. If someone have than please send it to me.
Thanx & Regards,
Rahul TaleleHI,
SEE THE SAMPLE REPORT
Fringe Benefit Tax Report
Program Name :
Object ID :
Functional Analyst :
Programmer :
Start date :
Initial CTS :
Description : FRINGE Benefit Tax
Includes :
Function Modules :
Logical database :
Transaction Code :
External references :
Modification Log
Date | Modified by | CTS number | Comments
| | | Initial Version *
REPORT ZFI_FBT NO STANDARD PAGE HEADING LINE-SIZE 255.
TYPE-POOLS: SLIS.
TYPES : BEGIN OF
T_BSIS,
BUKRS TYPE BUKRS, " Company Code
HKONT TYPE HKONT, " General Ledger Account
GJAHR TYPE GJAHR,
BELNR TYPE BELNR_D, " Accounting Document Number
BUDAT TYPE BUDAT, " Posting Date in the Document
BLDAT TYPE BLDAT, " Document Date in Document
XBLNR TYPE XBLNR1, " Reference Document Number
BSCHL TYPE BSCHL, " Posting Key
DMBTR TYPE DMBTR, " Amount in Local Currency
AUFNR TYPE AUFNR_NEU, " Order Number
NONFBT TYPE DMBTR, " non fbt amount
SUBFBT TYPE DMBTR, " subject to fbt amount
ZFI_FBT TYPE ZFI_FBT, " Qualifying amount.
AMOUNT TYPE DMBTR,
FBTPAY TYPE DMBTR,
ZFI_PAY TYPE ZFI_PAY,
END OF T_BSIS,
T_IT_BSIS TYPE STANDARD TABLE OF T_BSIS.
TYPES : BEGIN OF T_FRINGE,
ZFI_HKONT TYPE HKONT,
ZFI_FBT TYPE ZFI_FBT,
ZFI_PAY TYPE ZFI_PAY,
END OF T_FRINGE,
T_IT_FRINGE TYPE STANDARD TABLE OF T_FRINGE.
DATA : GIT_FRINGE TYPE T_IT_FRINGE,
GWA_FRINGE TYPE T_FRINGE.
DATA : GIT_BSIS TYPE T_IT_BSIS,
GWA_BSIS TYPE T_BSIS.
DATA : G_HKONT TYPE HKONT,
G_BUDAT TYPE BUDAT,
G_AUFNR TYPE AUFNR_NEU.
FIELD-SYMBOLS : <BSIS> TYPE T_BSIS.
DATA : G_REPID TYPE SY-REPID,
GIT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GWA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CONSTANTS : C_50(2) TYPE C VALUE '50'.
SELECTION SCREEN DEFINITIONS
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_BUKRS TYPE BUKRS DEFAULT 'H901' OBLIGATORY.
SELECT-OPTIONS : S_HKONT FOR G_HKONT,
S_BUDAT FOR G_BUDAT.
*PARAMETERS : P_AUFNR TYPE AUFNR_NEU DEFAULT '000000100001' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
EVENTS
INITIALIZATION.
INITIALIZATION.
G_REPID = SY-REPID.
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
PERFORM GET_ZTABLE. " get data from ZFII_FRINGE table
START-OF-SELECTION.
START-OF-SELECTION.
PERFORM GET_DATA. " get data from BSIS table
IF NOT GIT_BSIS IS INITIAL.
PERFORM GET_PERCENTAGE. " to get the percentages from table ZFII_FRINGE
PERFORM CHK4_INTERNAL. " checking for the posting key wheather th document is reversed
" and checking wheather internal order is FBT or non-FBT
ENDIF.
END-OF-SELECTION.
END-OF-SELECTION.
IF NOT GIT_BSIS IS INITIAL.
PERFORM DISPLAY. " display ALV GRID display
ENDIF.
*& Form get_data
text
--> p1 text
<-- p2 text
FORM GET_DATA .
SELECT
BUKRS
HKONT
GJAHR
BELNR
BUDAT
BLDAT
XBLNR
BSCHL
DMBTR
AUFNR FROM BSIS
INTO TABLE GIT_BSIS
WHERE BUKRS EQ P_BUKRS AND
HKONT IN S_HKONT AND
BUDAT IN S_BUDAT.
IF SY-SUBRC NE 0.
MESSAGE I000(ZFI) WITH 'No data exist'.
EXIT.
ENDIF.
ENDFORM. " get_data
*& Form display
FORM DISPLAY .
PERFORM BUILD_FIELD_CATALOUGE.
PERFORM GET_EVENTS.
PERFORM DETERMINE_SORT_SEQUENCE.
PERFORM SUB_COMMENTERY_BUILD.
PERFORM ALV_DISPLAY.
ENDFORM. " display
*& Form build_field_catalouge
FORM BUILD_FIELD_CATALOUGE.
DATA : L_POS TYPE I.
L_POS = 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'HKONT' " InTab Field Name
'GIT_BSIS' " InTab Name
'10' " Output Length
'GL Account' " Column Name Text
' ' " Datatype
'X' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
' '. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'BELNR' " InTab Field Name
'GIT_BSIS' " InTab Name
'10' " Output Length
'Document No.' " Column Name Text
' ' " Datatype
'X' " Key?
'1' " Row Position
'X' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
' '. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'BUDAT' " InTab Field Name
'GIT_BSIS' " InTab Name
'10' " Output Length
'Posting Date' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
' '. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'BLDAT' " InTab Field Name
'GIT_BSIS' " InTab Name
'10' " Output Length
'Docu. Date' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
' '. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'XBLNR' " InTab Field Name
'GIT_BSIS' " InTab Name
'16' " Output Length
'Ref. Doc. Number' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
'X'. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'DMBTR' " InTab Field Name
'GIT_BSIS' " InTab Name
'16' " Output Length
'Gross Amount' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
'X'. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'SUBFBT' " InTab Field Name
'GIT_BSIS' " InTab Name
'16' " Output Length
'FBT Amount' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
'X'. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'NONFBT' " InTab Field Name
'GIT_BSIS' " InTab Name
'16' " Output Length
'Non FBT Amount' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
'X'. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'ZFI_FBT' " InTab Field Name
'GIT_BSIS' " InTab Name
'12' " Output Length
'Percentage' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
' '. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'AMOUNT' " InTab Field Name
'GIT_BSIS' " InTab Name
'16' " Output Length
'Qualifying Amount' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
'X'. " Sum field?
L_POS = L_POS + 1 .
PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[] " Field Catalog
L_POS " Column Position
'FBTPAY' " InTab Field Name
'GIT_BSIS' " InTab Name
'12' " Output Length
'FBT payable' " Column Name Text
' ' " Datatype
' ' " Key?
'1' " Row Position
' ' " Hotspot
' ' " Emphasize
' ' " key_sel
' ' " justification
'X'. " Sum field?
ENDFORM. " build_field_catalouge
*& Form init_field_catalog
text
FORM INIT_FIELD_CATALOG USING P_GIT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV
PV_POS LIKE GWA_FIELDCAT-COL_POS
PV_FIELDNAME LIKE GWA_FIELDCAT-FIELDNAME
PV_TABNAME LIKE GWA_FIELDCAT-TABNAME
PV_OUTPUT LIKE GWA_FIELDCAT-OUTPUTLEN
PV_SELTEXT LIKE GWA_FIELDCAT-SELTEXT_M
PV_DATATYPE LIKE GWA_FIELDCAT-DATATYPE
PV_KEY LIKE GWA_FIELDCAT-KEY
PV_ROW LIKE GWA_FIELDCAT-ROW_POS
PV_HOTSPOT LIKE GWA_FIELDCAT-HOTSPOT
PV_EMPHASIZE LIKE GWA_FIELDCAT-EMPHASIZE
PV_KEY_SEL LIKE GWA_FIELDCAT-KEY_SEL
PV_JUST LIKE GWA_FIELDCAT-JUST
PV_SUM LIKE GWA_FIELDCAT-DO_SUM.
DATA: LT_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
LT_FIELDCAT-OUTPUTLEN = PV_OUTPUT.
LT_FIELDCAT-COL_POS = PV_POS.
LT_FIELDCAT-FIELDNAME = PV_FIELDNAME.
LT_FIELDCAT-TABNAME = PV_TABNAME.
LT_FIELDCAT-SELTEXT_M = PV_SELTEXT.
LT_FIELDCAT-KEY = PV_KEY.
LT_FIELDCAT-ROW_POS = PV_ROW.
LT_FIELDCAT-HOTSPOT = PV_HOTSPOT.
LT_FIELDCAT-EMPHASIZE = PV_EMPHASIZE.
LT_FIELDCAT-KEY_SEL = PV_KEY_SEL.
LT_FIELDCAT-DO_SUM = PV_SUM.
LT_FIELDCAT-JUST = PV_JUST.
LT_FIELDCAT-DATATYPE = PV_DATATYPE.
APPEND LT_FIELDCAT TO P_GIT_FIELDCAT.
CLEAR LT_FIELDCAT.
ENDFORM. " init_field_catalog
*& Form alv_display
text
--> p1 text
<-- p2 text
FORM ALV_DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = '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 = 'Fringe Benefit Tax'
I_GRID_SETTINGS =
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GIT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = GT_SORT
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = GT_EVENTS[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = GIT_BSIS
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. " alv_display
*& Form chk4_internal
text
--> p1 text
<-- p2 text
FORM CHK4_INTERNAL .
LOOP AT GIT_BSIS ASSIGNING <BSIS>.
IF <BSIS> IS ASSIGNED.
IF <BSIS>-BSCHL = C_50.
<BSIS>-DMBTR = <BSIS>-DMBTR * -1.
ENDIF.
IF NOT <bsis>-aufnr IS INITIAL.
IF <BSIS>-AUFNR = '000000100000'. " P_AUFNR.
<BSIS>-SUBFBT = <BSIS>-DMBTR.
<BSIS>-AMOUNT = ( <BSIS>-SUBFBT * <BSIS>-ZFI_FBT ) / 100.
ELSE.
IF <bsis>-aufnr = '000000100020'.
<BSIS>-NONFBT = <BSIS>-DMBTR.
ENDIF.
ENDIF.
<BSIS>-FBTPAY = ( <BSIS>-AMOUNT * <BSIS>-ZFI_PAY ) / 100.
ENDIF.
ENDLOOP.
UNASSIGN <BSIS>.
ENDFORM. " chk4_internal
*& Form get_ztable
text
--> p1 text
<-- p2 text
FORM GET_ZTABLE .
REFRESH : GIT_FRINGE.
SELECT HKONT
ZFI_FBT
ZFI_PAY
FROM ZFI_FBT_DETL
INTO TABLE GIT_FRINGE
FOR ALL ENTRIES IN s_hkont
WHERE HKONT IN S_HKONT.
CHECK SY-SUBRC EQ 0.
SORT GIT_FRINGE BY ZFI_HKONT.
ENDFORM. " get_ztable
*& Form get_percentage
text
--> p1 text
<-- p2 text
FORM GET_PERCENTAGE .
CLEAR : GWA_FRINGE.
LOOP AT GIT_BSIS ASSIGNING <BSIS>.
IF <BSIS> IS ASSIGNED.
READ TABLE GIT_FRINGE INTO GWA_FRINGE WITH KEY
ZFI_HKONT = <BSIS>-HKONT
BINARY SEARCH.
CHECK SY-SUBRC EQ 0.
<BSIS>-ZFI_FBT = GWA_FRINGE-ZFI_FBT.
<BSIS>-ZFI_PAY = GWA_FRINGE-ZFI_PAY.
ENDIF.
ENDLOOP.
UNASSIGN <BSIS>.
ENDFORM. " get_percentage
*& Form determine_sort_sequence
text
--> p1 text
<-- p2 text
FORM DETERMINE_SORT_SEQUENCE .
DATA : LS_SORT TYPE SLIS_SORTINFO_ALV.
LS_SORT-SPOS = 1. " Sort order
LS_SORT-FIELDNAME = 'HKONT'.
LS_SORT-TABNAME = 'GIT_BSIS'.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = 'X'. " Sub total allowed
APPEND LS_SORT TO GT_SORT.
CLEAR LS_SORT.
ENDFORM. " determine_sort_sequence
*& Form get_events
text
--> p1 text
<-- p2 text
FORM GET_EVENTS .
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
GC_FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = GT_EVENTS.
READ TABLE GT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO GT_EVENTS.
ENDIF.
READ TABLE GT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_USER_COMMAND TO LS_EVENT-FORM.
APPEND LS_EVENT TO GT_EVENTS.
ENDIF.
ENDFORM. " get_events
*& Form sub_commentery_build
text
--> p1 text
<-- p2 text
FORM SUB_COMMENTERY_BUILD .
DATA: LS_LINE TYPE SLIS_LISTHEADER.
DATA : L_LOW TYPE CHAR10,
L_HIGH TYPE CHAR10,
L_DATE TYPE CHAR25.
CONCATENATE S_BUDAT-LOW6(2) '.' S_BUDAT-LOW4(2) '.' S_BUDAT-LOW+0(4) INTO L_LOW.
CONCATENATE S_BUDAT-HIGH6(2) '.' S_BUDAT-HIGH4(2) '.' S_BUDAT-HIGH+0(4) INTO L_HIGH.
CONCATENATE L_LOW ' - ' L_HIGH INTO L_DATE.
***header
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-KEY: not used for this type
LS_LINE-INFO = 'Fringe Benefit Tax'.
APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
***Selection
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Company Code'.
LS_LINE-INFO = P_BUKRS.
APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Posting Date'.
LS_LINE-INFO = L_DATE.
APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
ENDFORM. " sub_commentery_build
FORM TOP_OF_PAGE *
When TOP-OF-PAGE will be fired , this event will be called and it
will use the contents of i_list_top_of_page for output in the header
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM. "top_of_page
*& Form USER_COMMAND
Called from within the ALV processes. Currently, '&IC1' is used to
process the hotspot and display the document 'picked' by the user.
FORM USER_COMMAND USING PV_UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
CLEAR : GWA_BSIS.
CASE PV_UCOMM.
WHEN '&IC1'.
READ TABLE GIT_BSIS INTO GWA_BSIS INDEX SELFIELD-TABINDEX.
CASE SELFIELD-SEL_TAB_FIELD.
WHEN 'GIT_BSIS-BELNR'.
IF NOT GWA_BSIS-BELNR IS INITIAL.
SET PARAMETER ID: 'BUK' FIELD GWA_BSIS-BUKRS,
'BLN' FIELD GWA_BSIS-BELNR,
'GJR' FIELD GWA_BSIS-GJAHR.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
WHEN OTHERS.
ENDCASE.
WHEN OTHERS.
ENDCASE.
CLEAR : GWA_BSIS.
ENDFORM. "user_command
*& Form SET_PF_STATUS
text
FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'.
ENDFORM. "SET_PF_STATUSENDFORM. "SET_PF_STATUS
AWARD POINTS IF USEFUL.... -
Reg logic required for selection-screen.
Hi,
i have one requirement
on selection screen 2 radio button
1 for service
2 for account
Parameter FILE LOCALFILE Filename
If the radiobutton ACCOUNT is selected the default name for file will be:
Rev_acc_com_&system_time_stamp&.dat
Elseif the radiobutton SERVICE is selected the default name for file will be:
Rev_srv_com_&system_time_stamp&.dat
some body can give the logic for this.take the following solution
data: tstamp type TZNTSTMPS.
data: filename type string.
call function 'CONVERT_INTO_TIMESTAMP'
exporting
I_DATLO = sy-datum
I_TIMLO = sy-uzeit
importing
E_TIMESTAMP = tstamp.
if ACCOUNT is selected then
concatenate 'Rev_srv_com_' tstamp '.dat' into filename.
else if SERVICE is selected then
concatenate 'Rev_srv_com_' tstamp '.dat' into filename.
the filename variable will be containing ur required file name..
reward points if useful....
Maybe you are looking for
-
Java.awt.IllegalComponentStateException in JTable
Hi folks, I am trying to write a JTable cell validation. Input data in a cell, if failure, prompt message and set focus & editing back to the cell. I've tried InputVerifier() but it doesn't work since I can easily use the mouse click to shift to othe
-
How to handle space in incoming file during fcc
Hi all, I have a scenario of file to proxy. In this case the incomming file is space delimited and it begins with space too i.e. every new line item has a space in the begining I have to remove that space. How can i handle it...please help. The fcc
-
IMac G5 won't sleep when I manually tell it.
Hi. Sometimes when I click sleep from the menu, nothing happens or it goes to sleep but wakes up straight away. If in the second scenario I ask it to sleep again it sleeps normally. I always have multiple accounts open (2 users) but have only had thi
-
Quartz 2D PDF Merge and encrypt
Hi, I am absolutely new to this forum and we (my company) are doing some IPad and IPhone Development. I have a Java background and are doing currently some technology proof with X-Code and Objective-C. I want to drag two (or more) pdf-files on the Do
-
I have the plexiglass speakers from my old iMac can i use them on other devices?
I have a pair of plexiglass speakers from my redundent iMac, having cleaned them up I would wish to reuse them, 2.5 jack -3.5mm jack not easy to find but not impossable however are there any other problems?