ALV GRID PF status.
Hi,
I am using the function module REUSE_ALV_GRID_DISPLAY and I have created the pf status
after keeping PF status in report when I download data into excel only header is getting downloaded into excel but line item data is missing in the excel
Please help me to sort out this issue.
Thanks in advance.
Hi,
In se41, create your pf status.
then in extras go to adjust templates.
In adjust templates, select List viewer. All the standard status for alv ll be imported.
Now change the application toolbar with your requirement.
Download and check now the excel sheet.
The same problem i had, and solved by doing this. It worked fine then.
Hope this helps.
Regards,
Dhasarathy. K
Similar Messages
-
Problem in pf status in alv grid
Hi ,
In alv grid in fm reuse_alv_grid_display under parameter I_CALLBACK_PF_STATUS_SET = STATUS
FORM STATUS_SET USING LS_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'XYZ' EXCLUDING EXTAB.
ENDFORM.
Now i have to set back & exit button in my std toolbar.
I double clicked on XYZ & then control moves to menu painter & i defined all above mentioned button in application toolbar.
I activated but the mentioned buttons are not displaying in output.
Anybody will suggest me what i have to do in this case??hi
good
go through this links
http://sap.ittoolbox.com/code/archives.asp?i=10&d=3603&a=s
http://sap.ittoolbox.com/code/archives.asp?i=10&d=1917&a=s
this ll give you complete idea about the pf status in alv.
thanks
mrutyun^ -
Regarding PF Status In ALV Grid Dispaly
Hi..
Can you please tell me how to set PF status in ALV Grid Display.
Regards
Sandeep.hi,
if u use REUSE_ALV_LIST_DISPLAY copy the standard GUI-Status named STANDARD from function group SALV in your program
if u use REUSE_ALV_GRID_DISPLAY_LVC or REUSE_ALV_GRID_DISPLAY copy the standard GUI-Status named STANDARD_FULLSCREEN from function group SLVC_FULLSCREEN in your program
after that you cas set the pf-status in this way:
>CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
> EXPORTING
> i_callback_program = sy-cprog
> i_callback_pf_status_set = 'STATUS'
> i_callback_user_command = 'USERCOMMAND'
> is_layout = st_layout
> it_fieldcat = st_fieldcat
> TABLES
> t_outtab = outtab
or
>CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
> EXPORTING
> i_callback_program = sy-cprog
> i_callback_pf_status_set = 'STATUS'
> i_callback_user_command = 'USERCOMMAND'
> is_layout_lvc = wa_slis_layout
> it_fieldcat_lvc = tb_slis_fieldcat
> TABLES
> t_outtab = tb_app
where USERCOMMAND and STATUS are 2 forms in your program.
>FORM status USING pfstat TYPE slis_t_extab.
> SET PF-STATUS 'STANDARD' EXCLUDING pfstat.
>ENDFORM.
>
> ...
>
>FORM usercommand USING okcode LIKE sy-ucomm
> wa_selfield TYPE slis_selfield.
> CASE okcode.
> ....
> ENDCASE
>ENDFORM.
Bye.
Marco -
How to capture the checkbox status in ALV Grid display
I need some immediate help regarding Grid ALV.
My Requirement: I need to display an ALV grid report along with checkboxes. Further, I need to provide an option wherein the user can checkboxes and select the records that I need to process further (by clicking the process button on the ALV Report).
My Query: The problem here is that I am not able to capture the status of the checkboxes. This means that I am not able to capture which of the records have been selected by checking their resp checkboxes.
Solutions that I have tried: I have tried capturing the same at user command by checking the value in slis_selfield. But all the records show the value as 1 for the checkbox field.
Kinldy suggest how to go about it.
I am not using Object Oriented ALV. Please suggest something to be used in ALV Grid display in 4.6C version.
Regards,
NamrataHere is a Sample code , it might help you
TABLES : sflight.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
DATA: BEGIN OF it_sflight OCCURS 0,
checkbox(1),
carrid LIKE sflight-carrid,
END OF it_sflight.
*layout
DATA: wa_layout TYPE slis_layout_alv.
*field catalog
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
wa_fieldcatalog TYPE slis_fieldcat_alv.
START-OF-SELECTION.
SELECT carrid FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_sflight.
END-OF-SELECTION.
CLEAR it_fieldcatalog.
REFRESH it_fieldcatalog.
wa_fieldcatalog-fieldname = 'CHECKBOX'.
wa_fieldcatalog-outputlen = '3'.
wa_fieldcatalog-col_pos = '1'.
wa_fieldcatalog-seltext_m = 'Chk'.
wa_fieldcatalog-checkbox = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'CARRID'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '2'.
wa_fieldcatalog-seltext_m = 'Carrid'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
is_layout = wa_layout
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcatalog
TABLES
t_outtab = it_sflight
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form USER_COMMAND
FORM user_command USING p_ucomm TYPE sy-ucomm
p_selfld TYPE slis_selfield.
CASE p_ucomm.
WHEN '&DATA_SAVE'.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
LOOP AT it_sflight WHERE checkbox = 'X'.
DELETE it_sflight INDEX sy-tabix.
ENDLOOP.
p_selfld-refresh = 'X'.
ENDCASE.
ENDFORM. "user_command -
PF status of Selection screen and ALV Grid
Hi,
I need to create a report where on clicking the<b> 'ENTER'</b> key on application toolbar on the <b>selection-screen</b> the processing logic should get executed ( instead of clicking execute pushbutton).
For this i need to capture the function code associated with ENTER key on selection screen. How can i find this?
Also , on clicking enter i have to display <b>an ALV grid</b> with the <b>SAVE</b> key activated on the toolbar.How can i activate SAVE key on application toolbar of ALV GRID. (<b>Selection-screen should not have save key</b> )
thanks,
vartikaHi
you can just copy the alv standard pf status into your alv.
goto se41.
enter "SAPLSLVC_FULLSCREEN"
then copy the standard pf status " STANDARD_FULLSCREEN" to your program "xyz".
in your prog, when you call the alv grid,
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = l_v_repid
i_callback_pf_status_set = 'SET_PF_STATUS' <----
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
tHEN CPOY PASTE THIS CODE:
NOTE: No need to make a perform for this....
* FORM SET_PF_STATUS *
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS '/FIR/RRF2S0BG_ALV'.
"Copy of standard pf_status from
ENDFORM. "set_pf_status
Now can see the full tool bar enabled in your alv grid.
delete all the unwanted buttons from your programs pf status .
Hope that helps.
Cheers
Ravish Garg.
<i>
Reward if useful</i> -
Hello Experts!
I've created a screen with an alv_grid and a custom pf_status, I have a custome button defined in the pf_status, I need to pass the command executed from the pf_status to the alv_grid.
Is this possible?
My user refuses to use the alv_grid toolbar.Hi there
Do the following
1) separate off the functions you want the standard SAP GUI (SE41) to do - I usually choose the standard 3 buttons BACK, EXIT, CANCEL and just use these in your PAI. ( You set the status in the PBO)
2) Now for the Grid toolbars you need to define event handlers for ON TOOLBAR, and ON USER COMMAND and have methods for these. You need to register the events as well.
I'm using my own ALV GRID class but it refrences CL_GUI_ALV_GRID so you could code something like this..
in the constructor
the variable z_object is simply a refrence to type cl_gui_alv_grid. GRID1 is also defined as a reference to cl_gui_alv_grid.
As an import parameter to the constructor I also pass the name of the program - which is quite useful as I can then in various methods of the class do a Perfom (XXXX) in program (yyyy) if found.
method constructor .
create object grid_container1
exporting
* container_name = 'CCONTAINER1'.
container_name = cfname.
create object grid1
exporting
i_parent = grid_container1.
set handler z_object->on_user_command for grid1.
set handler z_object->on_toolbar for grid1.
set handler z_object->handle_data_changed for grid1.
set handler z_object->handle_data_changed_finished for grid1.
set handler z_object->on_dubbelklik for grid1.
set handler z_object->on_hotspot for grid1.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
endmethod.
Now for the on_toolbar and on_user_command methods.
method on_toolbar .
type-pools icon.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'EXCEL' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move icon_xxl to ls_toolbar-icon.
move 'Excel' to ls_toolbar-quickinfo.
move 'EXCEL' to ls_toolbar-text.
append ls_toolbar to e_object->mt_toolbar.
perform toolbar in program (caller) if found
using e_object.
endmethod.
method on_user_command .
* FOR EVENT before_user_command OF cl_gui_alv_grid
* IMPORTING
* e_ucomm
* sender
case e_ucomm.
when 'EXIT'.
leave program.
when 'EXCEL'.
call method me->download_to_excel.
when 'SAVE'.
when 'PROC'.
call method me->process.
when 'REFR'.
call method me->refresh.
when 'SWITCH'.
call method me->switch.
when 'TEST'.
call method me->get_cell.
endcase.
endmethod.
The toolbar event is particularly useful if you want to add / remove standard functionality to the standard toolbar.
As I've definedined my class with SE24 rather than inline code then I don't need the FOR EVENT statement in the method -- if your class is ïn line "i.e part of the abap" then you'll need those statements..
When you now press one of the grid toolbar buttons your ON_USER_COMMAND Method will be executed with the FCODE assigned to the button passed as a parameter e_ucomm.
You can also intercept the Standard SAP ALV toolbars as well as the on user command event gets handled BEFORE the SAP code.
For example as I previously posted you can intercept say the standard sort ascending button (code &SORT_ASC) issue a popup and carry on.
Cheers
jimbo -
ALV grid to list processing and GUI status
Hi,
In a customized program the report output is in ALV grid which is interactive. On selecting a record and pressing SAVE button a BAPI runs in background. In order to display BAPI error message the leave to list-processing has been used. But GUI status is not working in list display and can not exit or go back from here to main selection screen.
when try to see program name & screen no it displays
Program - SAPLKKBL
Menu - STANDARD_FULLSCREEN
pls advise how to go back from list to main screen or ALV output.
thanks
anyaHi Anya,
As per my understanding, this is your prog flow:
*Main ALV Display.
*Select record.
*Click on Button SAVE.
*Handle Event.
*Call BAPI for processing based on selection.
Now at this point why dont you colect the error messages from the BAPI, and display it in a POP-UP ALV display?
You need not e very much worried about the PF status and all. Also this POP-UP will be placed on the MAIN ALV. So when you close the POP-UP it will come back to the main ALV.
By this when you press the BACK button of the main ALV, it will take you back to the selection scree.
Please let me know if i am missing something.
ags -
Pf status & user-command in alv grid
Hi Friends,
I have one query for ALV grid.
Actually my requirement is like that
Whenever the user double click on grid the control moves to transaction 'VA01' tcode.
I also wanted to set the gui status in ALV grid.
How to do it??
Plz tell me in detail.Very simple....
copy paste this code.... remember I have created a GUI Status called ZALV_STATUS.
So u will have to create this status to run ur program.
U can come back if u have any doubts...
*& Report Z_ALV_TRAINING_LIST_HOTSPOT
REPORT Z_ALV_TRAINING_LIST_HOTSPOT.
Type Pools Used **********
TYPE-POOLS : SLIS.
Internal Tables Declare ************
DATA : it_document type standard table of bkpf initial size 0 with header line,
IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
it_alv_event type SLIS_T_EVENT,
fl_layout type slis_layout_alv.
Select Data ***********
start-of-selection.
select * from bkpf into table it_document.
Make Field Catalog ******
PERFORM MAKE_FIELD_CATALOG.
Make Layout *********
perform sub_fill_layout.
Make Events Table *******
perform sub_Fill_alv_event.
Display ALV *********
PERFORM DISPLAY_ALV_LIST.
*& Form make_field_catalog
text
--> p1 text
<-- p2 text
FORM MAKE_FIELD_CATALOG .
data : wa type slis_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME =
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'bkpf'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = it_field_cat
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.
read table it_field_cat into wa index 3.
wa-hotspot = 'X'.
modify it_field_cat index 3 from wa.
ENDFORM. " make_field_catalog
*& Form display_alv_list
text
--> p1 text
<-- p2 text
FORM DISPLAY_ALV_LIST .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'SET_MY_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
IS_LAYOUT = fl_layout
IT_FIELDCAT = it_field_cat[]
IT_SORT =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT = '/TEST_VV'
IT_EVENTS = it_alv_event
TABLES
T_OUTTAB = it_document.
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_alv_list
*& Form sub_my_pf_event
text
--> p1 text
<-- p2 text
FORM sub_my_pf_event using p_comm type sy-ucomm p_sEL_FIELD TYPE SLIS_SELFIELD.
read table it_document index p_sel_field-tabindex.
set parameter id 'BLN' field it_document-belnr.
set parameter id 'BUK' field it_document-bukrs.
set parameter id 'GJR' field it_document-gjahr.
case p_comm.
when 'PICK'.
call transaction 'FB03' and skip first screen.
endcase.
ENDFORM. " sub_my_pf_event
*& Form sub_Fill_alv_event
text
--> p1 text
<-- p2 text
FORM sub_Fill_alv_event .
data : wa type slis_alv_event.
wa-name = 'USER_COMMAND'.
wa-form = 'SUB_MY_PF_EVENT'.
append wa to it_alv_event.
ENDFORM. " sub_Fill_alv_event
*& Form sub_fill_layout
text
--> p1 text
<-- p2 text
FORM sub_fill_layout .
fl_layout-f2code = 'PICK'.
fl_layout-box_fieldname = 'BELNR'.
ENDFORM. " sub_fill_layout
*& Form SET_MY_PF_STATUS
text
--> p1 text
<-- p2 text
FORM SET_MY_PF_STATUS USING p_rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZALV_STATUS'.
ENDFORM. " SET_MY_PF_STATUS
Plz award points if it was helpful....
Message was edited by:
Varun Verma -
Facing probelm in PF status in ALV Grid display
HI,
i have created a ALV grid intractive report in that i have a check box and Traffice lights , when user select the check box and press save then then traffice light color should changes to green it's doing well..but my problem is..for second time display i am calling same function module to display with chnaged traffice light color.here my probelm is after second time display when i press back it's taking me to first list not to the selection-screen. pls suggest me wot to do now for directly going to selection-screen.
Thanks,
saleem.
points to awarded for all usefull answers.Hi again,
1.
<b> and press save then</b> then traffice light color should changes to green it's doing well..but
U must have written some code
when the BOLD occurs.
2. This must be the call back command
(FORM subrouritine, which the alv call backs,
on a user command)
3. In the same u have to write.
4. For your reference,
just copy paste this code.
a) it will show records from t001 table
b) if u double-click on any row,
it will change the 2nd column to 'CLICKED'
and refresh the data again.
(it won't show alv once more in new screen)
c) then when u do back, it will go back.
d) See BOLD code.
5.
REPORT abc.
TYPE-POOLS : slis.
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
IMPORTANT.
<b>
data : m type sy-index.
m = whatrow-tabindex.
itab-butxt = 'CLICKED'.
modify itab index m.
whatrow-refresh = 'X'.</b>
ENDFORM. "ITAB_user_command
regards,
amit m. -
ALV Grid- to avoid message in status bar
Hi,
When ever i am doing sum in ALV Grid. I got the following message in statusbar.
' The field BETRAG_ITEM cannot be totalled of field overflow '
I am using currency field of 13 length and 2 decimals (Output length as 18 characters). How can i will aviod this message. could you please help me.
For right answer i can reward the points.
Regards
Bhupal ReddyHI,
Make the output length in the fieldcat for the particular fields as 18.
reward if helpful,
regards,
nazeer -
Screen GUI Status Query ( ALV Grid)
Hi All,
I am having an ALV grid on a screen .
I want to check the contents of the grid at the press of enter button, at present i have to press the check button available on the ALV grid to check the contents of the grid.
Pls suggestMake sure that you set "ENTER" as the key which is to trigger the edit event.
call method alv_grid->set_table_for_first_display
exporting
is_layout = lt_layout
it_toolbar_excluding = lt_exclude
changing
it_outtab = ialv[]
it_fieldcatalog = fieldcat[].
<b>
* If cancelling points, register "ENTER" as event
* and create the event receiver
call method alv_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
</b>
* create Event Receiver
create object event_receiver.
* handler for ALV grid
set handler event_receiver->handle_data_changed for alv_grid.
Regards,
Rich Heilman -
First try with ALV Grid and Abap Objects
Hi,
this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
*& Report Z_PLAN_TEXT_UPLOAD *
REPORT z_plan_text_upload.
INCLUDE <icon>.
* Data Declaration
DATA:
gf_dynnr TYPE sy-dynnr,
gf_repid TYPE sy-repid.
DATA:
go_docking_container TYPE REF TO cl_gui_docking_container,
go_alv_grid TYPE REF TO cl_gui_alv_grid.
DATA:
gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat LIKE LINE OF gt_fieldcat.
TYPES:
BEGIN OF gy_text_input,
firma(20) TYPE c,
kostenstelle(20) TYPE c,
datenart1(10) TYPE c,
planjahr(10) TYPE c,
* planperiode TYPE co_perio,
planperiode(5) TYPE c,
datenart2(10) TYPE c,
planungposition(10) TYPE c,
* kostenart TYPE koart,
kostenart(10) TYPE c,
* planbetrag TYPE bapicurr_d,
planbetrag(20) TYPE c,
END OF gy_text_input.
DATA:
gt_text_input TYPE TABLE OF gy_text_input,
gs_text_input LIKE LINE OF gt_text_input.
* Local Class Definition
* Local Class Implementation
* Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK b1
WITH FRAME TITLE text-001.
SKIP.
PARAMETERS:
gp_file TYPE localfile,
gp_head TYPE checkbox DEFAULT 'X'.
SKIP.
PARAMETERS:
gp_gjahr LIKE coep-gjahr,
gp_versn LIKE coep-versn.
SELECTION-SCREEN END OF BLOCK b1.
* Initialization
INITIALIZATION.
DATA:
lf_sapworkdir TYPE string.
CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
CHANGING
sapworkdir = lf_sapworkdir
EXCEPTIONS
get_sapworkdir_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0 OR lf_sapworkdir = ''.
CALL METHOD cl_gui_frontend_services=>directory_get_current
CHANGING
current_directory = lf_sapworkdir
EXCEPTIONS
directory_get_current_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
CALL METHOD cl_gui_cfw=>flush.
ENDIF."sy-subrc <> 0 OR sapworkdir = ''
gp_file = lf_sapworkdir.
gf_dynnr = sy-dynnr.
gf_repid = sy-repid.
* At Selection-Screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
DATA:
lt_filetable TYPE filetable,
ls_filetable LIKE LINE OF lt_filetable,
lt_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
* INITIAL_DIRECTORY =
* MULTISELECTION =
* WITH_ENCODING =
CHANGING
file_table = lt_filetable
rc = lt_rc
* USER_ACTION =
* FILE_ENCODING =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 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.
READ TABLE lt_filetable INDEX 1
INTO
ls_filetable.
gp_file = ls_filetable-filename.
CALL METHOD cl_gui_cfw=>flush.
* Start-Of-Selection
START-OF-SELECTION.
DATA:
lf_filename LIKE filename-fileintern.
lf_filename = gp_file.
CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
EXPORTING
i_filename = lf_filename
i_servertyp = 'PRS '
i_fileformat = 'TXT'
* I_FIELD_SEPERATOR =
i_line_header = gp_head
* IMPORTING
* E_BIN_FILELENGTH =
TABLES
i_tab_receiver = gt_text_input
EXCEPTIONS
file_not_found = 1
close_failed = 2
authorization_failed = 3
open_failed = 4
conversion_failed = 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.
*------ Build the Field Catalog ---------------------------------------*
PERFORM build_fieldcatalog
CHANGING gt_fieldcat.
*------ Create the docking container ----------------------------------*
IF go_docking_container IS INITIAL.
CREATE OBJECT go_docking_container
EXPORTING
* PARENT =
repid = gf_repid
dynnr = gf_dynnr
* SIDE = go_docking_container->DOCK_AT_bottom
* EXTENSION = 200
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
* RATIO =
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
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.
ENDIF."go_docking_container IS INITIAL
*------ Create the ALV Grid -------------------------------------------*
IF go_alv_grid IS INITIAL.
CREATE OBJECT go_alv_grid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_docking_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.
ENDIF."go_alv_grid is initial
*------ Call ALV Grid -------------------------------------------------*
CALL METHOD go_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 =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_text_input
it_fieldcatalog = gt_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.
*& Form build_fieldcatalog
* text
* <--P_GT_FIELDCAT text
FORM build_fieldcatalog
CHANGING
pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'FIRMA' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Firma' .
ls_fcat-seltext = 'Firma' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'KOSTENSTELLE' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Kostenstelle' .
ls_fcat-seltext = 'Kostenstelle' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'DATENART1' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Datenart1' .
ls_fcat-seltext = 'Datenart1' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANJAHR' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Planjahr' .
ls_fcat-seltext = 'Planjahr' .
APPEND ls_fcat TO pt_fieldcat .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANPERIODE' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '5' .
ls_fcat-coltext = 'Planperiode' .
ls_fcat-seltext = 'Planperiode' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'DATENART2' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Datenart2' .
ls_fcat-seltext = 'Datenart2' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANUNGSPOSITION' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Planungsposition' .
ls_fcat-seltext = 'Planungsposition' .
APPEND ls_fcat TO pt_fieldcat .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'KOSTENART' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Kostenart' .
ls_fcat-seltext = 'Kostenart' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANBETRAG' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Planbetrag' .
ls_fcat-seltext = 'Planbetrag' .
APPEND ls_fcat TO pt_fieldcat .
ENDFORM. "build_fieldcatalogI have added some more functionality to my report. The good thing is, the report works as it should.
BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
1. Read planning data form text file into internal table
2. Display the internal table
3. Convert the data and display the converted result
4. Post the converted data to the system
5. Display log with messages
The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
*& Report Z_PLAN_TEXT_UPLOAD_TEST *
REPORT z_plan_text_upload_test.
INCLUDE <icon>.
* Data Declaration
DATA:
gf_okcode TYPE ui_func,
gf_balloghndl TYPE balloghndl.
DATA:
go_docking_container TYPE REF TO cl_gui_docking_container,
go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat LIKE LINE OF gt_fieldcat.
TYPES:
BEGIN OF gy_text_input,
firma(20) TYPE c,
kostenstelle(20) TYPE c,
datenart1(10) TYPE c,
planjahr(10) TYPE c,
* planperiode TYPE co_perio,
planperiode(5) TYPE c,
datenart2(10) TYPE c,
planungsposition(10) TYPE c,
* kostenart TYPE koart,
kostenart(10) TYPE c,
* planbetrag TYPE bapicurr_d,
planbetrag(20) TYPE c,
END OF gy_text_input.
DATA:
gt_text_input TYPE TABLE OF gy_text_input,
gs_text_input LIKE LINE OF gt_text_input.
* Bapi Strukturen
DATA:
gs_headerinfo TYPE bapiplnhdr,
gt_indexstructure TYPE TABLE OF bapiacpstru,
gs_indexstructure LIKE LINE OF gt_indexstructure,
gt_coobject TYPE TABLE OF bapipcpobj,
gs_coobject LIKE LINE OF gt_coobject,
gt_pervalue TYPE TABLE OF bapipcpval,
gs_pervalue LIKE LINE OF gt_pervalue,
gt_return TYPE TABLE OF bapiret2,
gs_return LIKE LINE OF gt_return,
gt_control TYPE TABLE OF bapipcpctrl,
gt_totvalue TYPE TABLE OF bapipcptot.
TYPES:
BEGIN OF gy_bapi_input,
version TYPE versn,
* perio TYPE co_perio,
fisc_year TYPE gjahr,
coobject(10) TYPE c,
cost_elem TYPE kstar,
wkgbtr01 TYPE wkgxxx,
wkgbtr02 TYPE wkgxxx,
wkgbtr03 TYPE wkgxxx,
wkgbtr04 TYPE wkgxxx,
wkgbtr05 TYPE wkgxxx,
wkgbtr06 TYPE wkgxxx,
wkgbtr07 TYPE wkgxxx,
wkgbtr08 TYPE wkgxxx,
wkgbtr09 TYPE wkgxxx,
wkgbtr10 TYPE wkgxxx,
wkgbtr11 TYPE wkgxxx,
wkgbtr12 TYPE wkgxxx,
END OF gy_bapi_input.
DATA:
gt_bapi_input TYPE TABLE OF gy_bapi_input,
gs_bapi_input LIKE LINE OF gt_bapi_input.
* Anwendungs-Log
DATA: gs_balsmsg TYPE bal_s_msg.
* Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK b1
WITH FRAME TITLE text-001.
PARAMETERS:
gp_file TYPE localfile,
gp_head TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN SKIP.
PARAMETERS:
gp_kokrs LIKE coep-kokrs,
gp_gjahr LIKE coep-gjahr,
gp_versn LIKE coep-versn,
gp_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b1.
* Local Class Definition
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive,
handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm,
handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive,
handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
* Local Class Implementation
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_toolbar_0100.
PERFORM handle_toolbar_0100
USING
e_object.
* e_interactive.
ENDMETHOD. "handle_toolbar_0100
METHOD handle_user_command_0100.
PERFORM handle_user_command_0100
USING
e_ucomm.
ENDMETHOD. "handle_user_command_0100
METHOD handle_toolbar_0200.
PERFORM handle_toolbar_0200
USING
e_object.
* e_interactive.
ENDMETHOD. "handle_toolbar_0100
METHOD handle_user_command_0200.
PERFORM handle_user_command_0200
USING
e_ucomm.
ENDMETHOD. "handle_user_command_0100
ENDCLASS. "lcl_event_handler IMPLEMENTATION
* Initialization
INITIALIZATION.
DATA:
lf_sapworkdir TYPE string.
CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
CHANGING
sapworkdir = lf_sapworkdir
EXCEPTIONS
get_sapworkdir_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0 OR lf_sapworkdir = ''.
CALL METHOD cl_gui_frontend_services=>directory_get_current
CHANGING
current_directory = lf_sapworkdir
EXCEPTIONS
directory_get_current_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
CALL METHOD cl_gui_cfw=>flush.
ENDIF."sy-subrc <> 0 OR sapworkdir = ''
gp_file = lf_sapworkdir.
* At Selection-Screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
DATA:
lt_filetable TYPE filetable,
ls_filetable LIKE LINE OF lt_filetable,
lt_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
* INITIAL_DIRECTORY =
* MULTISELECTION =
* WITH_ENCODING =
CHANGING
file_table = lt_filetable
rc = lt_rc
* USER_ACTION =
* FILE_ENCODING =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 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.
READ TABLE lt_filetable INDEX 1
INTO
ls_filetable.
gp_file = ls_filetable-filename.
CALL METHOD cl_gui_cfw=>flush.
* Start-Of-Selection
START-OF-SELECTION.
DATA:
lf_filename LIKE filename-fileintern.
PERFORM create_log.
gs_return-type = 'I'.
IF gp_test = 'X'.
gs_return-message = text-010.
ELSE.
gs_return-message = text-020.
ENDIF.
PERFORM add_log_message_free_text
USING
gs_return-type
gs_return-message.
lf_filename = gp_file.
CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
EXPORTING
i_filename = lf_filename
i_servertyp = 'PRS '
i_fileformat = 'TXT'
* I_FIELD_SEPERATOR =
i_line_header = gp_head
* IMPORTING
* E_BIN_FILELENGTH =
TABLES
i_tab_receiver = gt_text_input
EXCEPTIONS
file_not_found = 1
close_failed = 2
authorization_failed = 3
open_failed = 4
conversion_failed = 5
OTHERS = 6.
IF sy-subrc <> 0.
gs_balsmsg-msgty = sy-msgty.
gs_balsmsg-msgid = sy-msgid.
gs_balsmsg-msgno = sy-msgno.
gs_balsmsg-msgv1 = sy-msgv1.
gs_balsmsg-msgv2 = sy-msgv2.
gs_balsmsg-msgv3 = sy-msgv3.
gs_balsmsg-msgv4 = sy-msgv4.
PERFORM add_log_message
USING
gs_balsmsg.
ENDIF.
CALL SCREEN '0100'.
*& Module status_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
*------ Create the docking container ----------------------------------*
IF go_docking_container IS INITIAL.
CREATE OBJECT go_docking_container
EXPORTING
parent = cl_gui_container=>screen0
* repid = gf_repid
* dynnr = gf_dynnr
* SIDE = go_docking_container->DOCK_AT_bottom
* EXTENSION = 200
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
ratio = 95
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
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.
*------ Expand docking container to full screen -------------------*
CALL METHOD go_docking_container->set_extension
EXPORTING
extension = 99999 "full-screen size !!!
EXCEPTIONS
cntl_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.
ENDIF."go_docking_container IS INITIAL
*------ Link docking container to screen ------------------------------*
CALL METHOD go_docking_container->link
EXPORTING
repid = sy-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 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.
*------ Build the Field Catalog ---------------------------------------*
PERFORM build_fieldcatalog_input
CHANGING gt_fieldcat.
*------ Create the ALV Grid -------------------------------------------*
IF go_alv_grid_0100 IS INITIAL.
CREATE OBJECT go_alv_grid_0100
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_docking_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.
ENDIF."go_alv_grid_0100 is initial
*------ Create instance for event handler -----------------------------*
DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
CREATE OBJECT go_event_handler_0100.
*------ Register event handler ----------------------------------------*
SET HANDLER go_event_handler_0100->handle_toolbar_0100
FOR go_alv_grid_0100.
SET HANDLER go_event_handler_0100->handle_user_command_0100
FOR go_alv_grid_0100.
*------ Call ALV Grid -------------------------------------------------*
CALL METHOD go_alv_grid_0100->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 =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_text_input
it_fieldcatalog = gt_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.
*---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
ENDMODULE. " status_0100 OUTPUT
*& Module status_0200 OUTPUT
* text
MODULE status_0200 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
*------ Create the docking container ----------------------------------*
IF go_docking_container IS INITIAL.
CREATE OBJECT go_docking_container
EXPORTING
parent = cl_gui_container=>screen0
* repid = gf_repid
* dynnr = gf_dynnr
* SIDE = go_docking_container->DOCK_AT_bottom
* EXTENSION = 200
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
ratio = 95
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
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.
*------ Expand docking container to full screen -------------------*
CALL METHOD go_docking_container->set_extension
EXPORTING
extension = 99999
EXCEPTIONS
cntl_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.
ENDIF."go_docking_container IS INITIAL
*------ Link docking container to screen ------------------------------*
CALL METHOD go_docking_container->link
EXPORTING
repid = sy-repid
dynnr = '0200'
* CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 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.
*------ Build the Field Catalog---------------------------------------*
PERFORM build_fieldcatalog_bapi_input
CHANGING
gt_fieldcat.
*------ Create the ALV Grid -------------------------------------------*
IF go_alv_grid_0200 IS INITIAL.
CREATE OBJECT go_alv_grid_0200
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = go_docking_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.
ENDIF."go_alv_grid_0200 is initial
*------ Create instance for event handler -----------------------------*
DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
CREATE OBJECT go_event_handler_0200.
*------ Register event handler ----------------------------------------*
SET HANDLER go_event_handler_0200->handle_toolbar_0200
FOR go_alv_grid_0200.
SET HANDLER go_event_handler_0200->handle_user_command_0200
FOR go_alv_grid_0200.
*------ Call ALV Grid -------------------------------------------------*
CALL METHOD go_alv_grid_0200->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 =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_bapi_input
it_fieldcatalog = gt_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.
*---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
CALL METHOD go_alv_grid_0200->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.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = go_alv_grid_0200.
ENDMODULE. " status_0200 OUTPUT
*& Module user_command_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gf_okcode.
WHEN 'BACK' OR 'END' OR 'CANC'.
PERFORM exit_program.
WHEN OTHERS.
ENDCASE.
CLEAR gf_okcode.
ENDMODULE. " user_command_0100 INPUT
*& Module user_command_0200 INPUT
* text
MODULE user_command_0200 INPUT.
CASE gf_okcode.
WHEN 'BACK' OR 'END' OR 'CANC'.
PERFORM exit_program.
WHEN OTHERS.
ENDCASE.
CLEAR gf_okcode.
ENDMODULE. " user_command_0200 INPUT
*& Form build_fieldcatalog
* text
* <--P_GT_FIELDCAT text
FORM build_fieldcatalog_input
CHANGING
pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CLEAR pt_fieldcat.
ls_fcat-fieldname = 'FIRMA' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Firma' .
ls_fcat-seltext = 'Firma' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'KOSTENSTELLE' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'CO-Objekt' .
ls_fcat-seltext = 'CO-Objekt' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'DATENART1' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Datenart1' .
ls_fcat-seltext = 'Datenart1' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANJAHR' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Planjahr' .
ls_fcat-seltext = 'Planjahr' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANPERIODE' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '5' .
ls_fcat-coltext = 'Planperiode' .
ls_fcat-seltext = 'Planperiode' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'DATENART2' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Datenart2' .
ls_fcat-seltext = 'Datenart2' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANUNGSPOSITION' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Planungsposition' .
ls_fcat-seltext = 'Planungsposition' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'KOSTENART' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Kostenart' .
ls_fcat-seltext = 'Kostenart' .
APPEND ls_fcat TO pt_fieldcat .
ls_fcat-fieldname = 'PLANBETRAG' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Planbetrag' .
ls_fcat-seltext = 'Planbetrag' .
APPEND ls_fcat TO pt_fieldcat .
ENDFORM. "build_fieldcatalog
*& Form handle_toolbar_0100
* text
* -->P_E_OBJECT text
* -->P_E_INTERACTIVE text
FORM handle_toolbar_0100
USING
po_object TYPE REF TO cl_alv_event_toolbar_set.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
ls_toolbar-butn_type = 0.
ls_toolbar-function = 'KONV'.
ls_toolbar-quickinfo = 'Konvertieren'.
ls_toolbar-text = 'Konvertieren'.
ls_toolbar-disabled = ' '.
APPEND ls_toolbar TO po_object->mt_toolbar.
ENDFORM. " handle_toolbar_0100
*& Form handle_user_command_0100
* text
* -->P_E_UCOMM text
FORM handle_user_command_0100
USING
pf_ucomm TYPE syucomm.
CASE pf_ucomm.
WHEN 'KONV'.
PERFORM convert_data.
ENDCASE.
ENDFORM. " handle_user_command_0100
*& Form exit_program
* text
* --> p1 text
* <-- p2 text
FORM exit_program.
CALL METHOD go_alv_grid_0100->free.
IF NOT go_alv_grid_0200 IS INITIAL.
CALL METHOD go_alv_grid_0200->free.
ENDIF.
CALL METHOD go_docking_container->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
* add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = sy-repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form handle_toolbar_0200
* text
* -->P_E_OBJECT text
* -->P_E_INTERACTIVE text
FORM handle_toolbar_0200
USING
po_object TYPE REF TO cl_alv_event_toolbar_set.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
ls_toolbar-butn_type = 0.
ls_toolbar-function = 'POST'.
ls_toolbar-quickinfo = 'Buchen'.
ls_toolbar-text = 'Buchen'.
ls_toolbar-disabled = ' '.
APPEND ls_toolbar TO po_object->mt_toolbar.
ENDFORM. " handle_toolbar_0200
*& Form handle_user_command_0200
* text
* -->P_E_UCOMM text
FORM handle_user_command_0200
USING
pf_ucomm TYPE syucomm.
CASE pf_ucomm.
WHEN 'POST'.
PERFORM post.
ENDCASE.
ENDFORM. " handle_user_command_0200
*& Form convert_data
* text
* --> p1 text
* <-- p2 text
FORM convert_data.
DATA: lf_perio(3) TYPE n.
LOOP AT gt_text_input INTO gs_text_input.
TRANSLATE gs_text_input-planbetrag USING '. '.
TRANSLATE gs_text_input-planbetrag USING ',.'.
CONDENSE gs_text_input-planbetrag.
gs_bapi_input-version = gp_versn.
gs_bapi_input-fisc_year = gp_gjahr.
gs_bapi_input-coobject = gs_text_input-kostenstelle.
gs_bapi_input-cost_elem = gs_text_input-kostenart.
lf_perio = gs_text_input-planperiode.
CASE lf_perio.
WHEN '001'.
gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
WHEN '002'.
gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
WHEN '003'.
gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
WHEN '004'.
gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
WHEN '005'.
gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
WHEN '006'.
gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
WHEN '007'.
gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
WHEN '008'.
gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
WHEN '009'.
gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
WHEN '010'.
gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
WHEN '011'.
gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
WHEN '012'.
gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
ENDCASE.
COLLECT gs_bapi_input INTO gt_bapi_input.
CLEAR gs_bapi_input.
ENDLOOP. "at gt_text_input
CALL SCREEN 0200.
ENDFORM. " convert_data
*& Form build_fieldcatalog_bapi_input
* text
* <--P_GT_FIELDCAT text
FORM build_fieldcatalog_bapi_input
CHANGING
pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CLEAR pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'VERSION' .
ls_fcat-ref_table = 'BAPIPLNHDR' .
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'FISC_YEAR' .
ls_fcat-ref_table = 'BAPIPLNHDR' .
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'COOBJECT' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'CO-Objekt' .
ls_fcat-seltext = 'CO-Objekt' .
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'COST_ELEM' .
ls_fcat-ref_table = 'BAPIPCPVAL' .
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR01'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR02'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR03'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR04'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR05'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR06'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR07'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR08'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR09'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR10'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR11'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
CLEAR ls_fcat.
ls_fcat-fieldname = 'WKGBTR12'.
ls_fcat-ref_table = 'COEP' .
ls_fcat-ref_field = 'WKGBTR'.
APPEND ls_fcat TO pt_fieldcat .
ENDFORM. " build_fieldcatalog_bapi_input
*& Form post
* text
* --> p1 text
* <-- p2 text
FORM post.
DATA:
lf_index(6) TYPE n,
lf_kostl LIKE csks-kostl,
lf_aufnr LIKE aufk-aufnr,
lf_kstar LIKE cska-kstar.
DATA:
lt_csks TYPE TABLE OF csks.
break c5085345.
* Header
gs_headerinfo-co_area = gp_kokrs.
gs_headerinfo-fisc_year = gp_gjahr.
gs_headerinfo-period_from = '001'.
gs_headerinfo-period_to = '012'.
gs_headerinfo-version = gp_versn.
gs_headerinfo-plan_currtype = 'C'.
LOOP AT gt_bapi_input INTO gs_bapi_input.
* Fill index structure
CLEAR gs_indexstructure.
lf_index = sy-tabix.
gs_indexstructure-object_index = lf_index.
gs_indexstructure-value_index = lf_index.
gs_indexstructure-attrib_index = '000000'.
INSERT gs_indexstructure INTO TABLE gt_indexstructure.
* Fill coobject
CLEAR gs_coobject.
gs_coobject-object_index = lf_index.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gs_bapi_input-coobject
IMPORTING
output = lf_kostl.
SELECT * FROM csks INTO TABLE lt_csks
WHERE
kokrs = gp_kokrs AND
kostl = lf_kostl.
IF sy-subrc = 0.
gs_coobject-costcenter = lf_kostl.
ELSE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gs_bapi_input-coobject
IMPORTING
output = lf_aufnr.
CALL FUNCTION 'K_ORDER_READ'
EXPORTING
aufnr = lf_aufnr
EXCEPTIONS
not_found = 1.
IF NOT sy-subrc = 0.
gs_return-type = 'E'.
gs_return-message+0(10) = 'CO-Objekt '.
gs_return-message+10(10) = gs_bapi_input-coobject.
gs_return-message+20(20) = ' existiert nicht.'.
CONDENSE gs_return-message.
PERFORM add_log_message_free_text
USING
gs_return-type
gs_return-message.
EXIT.
ENDIF. "IF NOT sy-subrc = 0
gs_coobject-orderid = lf_aufnr.
ENDIF. "sy-subrc = 0
INSERT gs_coobject INTO TABLE gt_coobject.
* Period value
gs_pervalue-value_index = lf_index.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gs_bapi_input-cost_elem
IMPORTING
output = lf_kstar.
gs_pervalue-cost_elem = lf_kstar.
gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
INSERT gs_pervalue INTO TABLE gt_pervalue.
ENDLOOP. "at gt_bapi_input
* Buchungsbaustein
CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
EXPORTING
header_info = gs_headerinfo
testrun = gp_test
* DELTA = ' '
TABLES
idx_structure = gt_indexstructure
object = gt_coobject
per_value = gt_pervalue
tot_value = gt_totvalue
contrl = gt_control
return = gt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
LOOP AT gt_return INTO gs_return.
gs_balsmsg-msgty = gs_return-type.
gs_balsmsg-msgid = gs_return-id.
gs_balsmsg-msgno = gs_return-number.
gs_balsmsg-msgv1 = gs_return-message_v1.
gs_balsmsg-msgv2 = gs_return-message_v2.
gs_balsmsg-msgv3 = gs_return-message_v3.
gs_balsmsg-msgv4 = gs_return-message_v4.
PERFORM add_log_message
USING
gs_balsmsg.
ENDLOOP. "AT gt_return
PERFORM show_log.
ENDFORM. " post
*& Form create_log
* text
* --> p1 text
* <-- p2 text
FORM create_log .
DATA: ls_balslog TYPE bal_s_log.
* Einige Verwaltungsdaten
ls_balslog-extnumber = 'ZPLAN010'.
ls_balslog-aluser = sy-uname.
ls_balslog-alprog = sy-repid.
* Create
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = ls_balslog
* IMPORTING
* e_log_handle = gf_balloghndl
EXCEPTIONS
log_header_inconsistent = 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. " create_log
*& Form add_log_message
* text
* -->P_GS_BALSMSG text
FORM add_log_message
USING
ps_balsmsg TYPE bal_s_msg.
break c5085345.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
* I_LOG_HANDLE =
i_s_msg = ps_balsmsg
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
log_not_found = 1
msg_inconsistent = 2
log_is_full = 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.
ENDFORM. " add_log_messa
*& Form add_log_message_free_text
* text
* -->P_GS_RETURN_TYPE text
* -->P_GS_RETURN_MESSAGE text
FORM add_log_message_free_text
USING
ps_type
ps_message.
CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
EXPORTING
* I_LOG_HANDLE =
i_msgty = ps_type
* I_PROBCLASS = '4'
i_text = ps_message
* I_S_CONTEXT =
* I_S_PARAMS =
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
log_not_found = 1
msg_inconsistent = 2
log_is_full = 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.
ENDFORM. " add_log_message_free_text
*& Form show_log
* text
* --> p1 text
* <-- p2 text
FORM show_log .
DATA:
l_s_display_profile TYPE bal_s_prof.
* get display profile
CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
IMPORTING
e_s_display_profile = l_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* use grid for display if wanted
l_s_display_profile-use_grid = 'X'.
* set report to allow saving of variants
l_s_display_profile-disvariant-report = sy-repid.
* when you use also other ALV lists in your report,
* please specify a handle to distinguish between the display
* variants of these different lists, e.g:
l_s_display_profile-disvariant-handle = 'LOG'.
* call display function module
* We do not specify any filter (like I_S_LOG_FILTER, ...,
* I_T_MSG_HANDLE) since we want to display all logs available
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = l_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Help needed for editable alv grid program
hi,
Can you please tell me how to set a update button in application toolbar of alv griv without suppressing it and how to write the code for that update button so that if I change my editable column data and press the update button my updated data should be stored in my database table.
the code what i wrote is:
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_final,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
END OF t_final.
DATA: i_final TYPE STANDARD TABLE OF t_final INITIAL SIZE 0,
wa_final TYPE t_final.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = i_final
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_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INTO TABLE i_final WHERE avbeln = bvbeln.
ENDFORM. " DATA_RETRIEVAL
thanks in advance.hi sudhir,
thanks for ur reply.
after seeing the code u send to me i made changes to my program.but still when i click on update button,nothing is happening.can u please suggest me an idea.
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
TYPES: BEGIN OF t_final,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
END OF t_final.
DATA: i_final TYPE STANDARD TABLE OF t_final WITH HEADER LINE,
wa_final TYPE t_final.
*DATA:i_final LIKE vbap OCCURS 0.
*DATA:wa_final LIKE vbap.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'GUI_STAT'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = it_events
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = i_final
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_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INTO TABLE i_final WHERE avbeln = bvbeln.
ENDFORM. " DATA_RETRIEVAL
FORM GUI_STAT *
--> RT_EXTAB *
FORM gui_stat USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'UPDATE' EXCLUDING rt_extab.
ENDFORM.
FORM USER_COMMAND *
--> U_COMM *
--> RS_SELFIELD *
FORM user_command USING u_comm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA:selfield TYPE slis_selfield.
CASE u_comm.
WHEN 'UPDATE'.
LOOP AT i_final ."into wa_final.
i_final-matnr = vbap-matnr.
update (vbap) from table i_final.
IF sy-subrc = 0.
MESSAGE s000(0) WITH 'records updated successfully'.
ENDIF.
ENDLOOP.
ENDCASE.
ENDFORM. -
Regarding column editing in alv grid
hi experts,
i m using alv grid display for my report layout what i want that after the output dispaly when the user will select my customized button "change the amount column" then after pressing this my amount column will become editable and user can put there new aount for this i have used this codes but it is not working plz help me to sort out this,
for u here is my code.
FORM DISPLAY_LIST .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
is_layout = i_layout
it_fieldcat = i_fieldtab
i_grid_title = 'Production Incentive Details'
I_CALLBACK_PF_STATUS_SET = 'SET_PFSTATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
it_events = global_events
TABLES
t_outtab = itab_final
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_LIST
*& Form SET_PFSTATUS
text
-->RT_EXTAB text
FORM SET_PFSTATUS USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'ZPINCENTIVE' .
EXCLUDING rt_extab..
ENDFORM. " CREATE_PFSTATUS
*& Form user_command
text
-->R_UCOMM text
-->RS_SELFIELD text
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
*BREAK-POINT.
when '&CHANGED'. "for change the amount button.
read table i_fieldtab into s_fieldtab with key FIELDNAME = 'AMOUNT'.
if sy-subrc = 0.
move:sy-tabix to index,
'X' to s_fieldtab-edit.
modify:i_fieldtab index index from s_fieldtab.
clear:s_fieldtab.
endif.solved by own
-
Regarding Alv Grid Totals_text is not Printing
Hi All,
I am presently working in Alv Grid dispaly.
I need to dispaly Totals_Text = 'Totals'. But this text is not displaying in my output dispaly.i am copying my code here.
Code:
REPORT ZFTRSERV NO STANDARD PAGE HEADING
MESSAGE-ID YV
LINE-SIZE 255.
TABLES: BSIS, "Accounting: Secondary Index for G/L Accounts
BSAS, "Accounting: Secondary Index for G/L Accounts (Cleared Items)
BSID, "Accounting: Secondary Index for Customers
BKPF, "Accounting Document Header
ITCPP. "SAPscript output parameters
TYPE-POOLS: SLIS. "ALV Declarations
$$********************************************************************
$$ GLOBAL TYPES
$$ NAMING CONVENTION: "Y_NAME"
$$********************************************************************
*eject
$$********************************************************************
$$ GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
$$ NAMING CONVENTION: "I_NAME"
$$********************************************************************
$$********************************************************************
$$ GLOBAL INTERNAL TABLES (CUSTOM STRUCTURE)
$$ NAMING CONVENTION: "T_NAME"
$$********************************************************************
*eject
$$********************************************************************
$$ GLOBAL FIELD-SYMBOLS
$$ NAMING CONVENTION: "<FS_NAME>"
$$********************************************************************
FIELD-SYMBOLS: <FS_BSIS> TYPE Y_BSIS.
$$********************************************************************
$$ MACROS DECLARATION
$$ NAMING CONVENTION: M_NAME
$$********************************************************************
$$********************************************************************
$$ PARAMETERS & SELECT-OPTIONS
$$ NAMING CONVENTION: "P_NAME" & "S_NAME"
$$********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK SS01 WITH FRAME TITLE TEXT-B01.
GENERAL SELECTIONS
SELECT-OPTIONS: S_BUKRS FOR BSIS-BUKRS OBLIGATORY,
S_HKONT FOR BSIS-HKONT OBLIGATORY,
S_BLART FOR BSIS-BLART,
S_BELNR FOR BSIS-BELNR.
SELECTION-SCREEN END OF BLOCK SS01.
SELECTION-SCREEN BEGIN OF BLOCK SS02 WITH FRAME TITLE TEXT-B02.
OPEN ITEMS:
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS P_OPIT LIKE ITEMSET-XOPSEL RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) TEXT-003 FOR FIELD P_OPIT.
SELECTION-SCREEN END OF LINE.
PARAMETERS P_STIDA LIKE RFPDO-ALLGSTID DEFAULT SY-DATLO.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN: COMMENT (12) BLANK1,
COMMENT (20) TEXT-006 FOR FIELD P_OSST.
PARAMETERS: P_OSST AS CHECKBOX DEFAULT SPACE.
SELECTION-SCREEN: COMMENT (12) BLANK2,
COMMENT (20) TEXT-007 FOR FIELD P_OUTD.
PARAMETERS:P_OUTD LIKE ITCPP-TDDEST.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK SS03.
*eject
$$********************************************************************
$$ INITIALIZATION
$$********************************************************************
INITIALIZATION.
CLEAR: E_BSID,
E_BSIS,
E_BSAS,
E_BKPF,
E_TOTAL,
E_SUMSHET_OPEN,
E_SUMSHET_CLEAR,
E_SUMSHET_TOTAL,
E_CATLOG,
E_ALV_LAYOUT.
FREE: T_BSID,
T_BSIS,
T_BSAS,
T_BKPF,
T_TOTAL,
T_SUMSHET_OPEN,
T_SUMSHET_CLEAR,
T_SUMSHET_TOTAL.
*eject
$$********************************************************************
$$ AT SELECTION-SCREEN
$$********************************************************************
AT SELECTION-SCREEN .
*eject
$$********************************************************************
$$ START-OF-SELECTION
$$********************************************************************
START-OF-SELECTION.
To Get data from tables
PERFORM F_OUT_DATA_RETRIEVEL.
*eject
$$********************************************************************
$$ END-OF-SELECTION
$$********************************************************************
END-OF-SELECTION.
To Display ALV Grid Layout
PERFORM F_ALV_DATA_RETRIVAL.
*eject
*& Form f_out_data_retrievel
data retrival for Open,Clear and All items
FORM F_OUT_DATA_RETRIEVEL.
IF P_OPIT EQ C_X.
*open items is selected data will be retrieved from BSIS table.
PERFORM F_OPEN_ITEMS.
TO GET DATA FOR SUMMARY SHEET OPEN ITEMS.
PERFORM F_GET_OPEN_SUMSHET.
ENDIF.
ENDFORM. " f_out_data_retrievel
*& Form F_OPEN_ITEMS
getting data for Open items from BSIS Table
FORM F_OPEN_ITEMS .
SELECT BUKRS
HKONT
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI
BUDAT
BLDAT
BLART
BSCHL
MWSKZ
DMBTR
SGTXT
FROM BSIS
INTO CORRESPONDING FIELDS OF TABLE T_BSIS
WHERE BUKRS IN S_BUKRS
AND HKONT IN S_HKONT
AND BLART IN S_BLART
AND BELNR IN S_BELNR
AND AUGDT NE P_STIDA .
IF SY-SUBRC NE C_0.
MESSAGE S999 WITH text-030.
ENDIF.
PERFORM F_GET_DATA_BSIS.
ENDFORM. " F_OPEN_ITEMS
To get the Entry date and Reference Key2
PERFORM F_GET_DATA_BSIS.
*& Form F_GET_DATA_BSAS
GETTING DATA FROM BSAS TABLE
FORM F_GET_DATA_BSAS .
DATA: W_TABIX TYPE SY-TABIX.
UNASSIGN <FS_BSAS>.
GETTING DATA FROM BKPF AND BSID TABLES
LOOP AT T_BSAS ASSIGNING <FS_BSAS>.
CLEAR: E_BKPF,
E_BSID,
W_TABIX.
MOVE SY-TABIX TO W_TABIX.
SELECT SINGLE BUKRS
BELNR
GJAHR
CPUDT
BUDAT
FROM BKPF
INTO CORRESPONDING FIELDS OF E_BKPF
WHERE BUKRS EQ E_BSAS-BUKRS
AND BLART EQ E_BSAS-BLART
AND BELNR EQ E_BSAS-BELNR
AND BUDAT EQ E_BSAS-BUDAT.
IF SY-SUBRC EQ C_0.
MOVE E_BKPF-CPUDT TO <FS_BSAS>-CPUDT.
MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
TRANSPORTING CPUDT.
ENDIF.
SELECT SINGLE BUKRS
KUNNR
UMSKS
UMSKZ
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI
XREF2
FROM BSID
INTO CORRESPONDING FIELDS OF E_BSID
WHERE BUKRS EQ E_BSAS-BUKRS
AND BELNR EQ E_BSAS-BELNR
AND BLART EQ E_BSAS-BLART
AND BUDAT EQ E_BSAS-BUDAT.
IF SY-SUBRC EQ C_0.
MOVE E_BSID-XREF2 TO <FS_BSAS>-XREF2.
FREE T_BSID.
MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
TRANSPORTING XREF2.
ENDIF.
<FS_BSAS>-IDATE = SY-DATUM.
<FS_BSAS>-IEDAT = <FS_BSAS>-CPUDT - <FS_BSAS>-ZUONR.
<FS_BSAS>-PTIME = SY-DATUM - <FS_BSAS>-CPUDT.
MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
TRANSPORTING IEDAT
PTIME
IDATE.
ENDLOOP.
SORT T_BSAS BY HKONT XREF2 CPUDT.
ENDFORM. " F_GET_DATA_BSAS
*& Form F_GET_DATA_BSIS
GETTING DATA FROM BSIS TABLE
FORM F_GET_DATA_BSIS .
DATA: W_TABIX TYPE SY-TABIX,
W_SGTXT LIKE BSIS-SGTXT,
W_SGTXT1 LIKE BSIS-SGTXT,
W_SORTL LIKE KNA1-SORTL.
CLEAR: E_BKPF,
E_BSID,
W_TABIX,
W_SGTXT,
W_SGTXT1,
W_SORTL.
GETTING DATA FROM BKPF AND BSID TABLES
LOOP AT T_BSIS INTO E_BSIS.
MOVE SY-TABIX TO W_TABIX.
SELECT SINGLE BUKRS
BELNR
GJAHR
CPUDT
BUDAT
FROM BKPF
INTO CORRESPONDING FIELDS OF E_BKPF
WHERE BUKRS EQ E_BSIS-BUKRS
AND BLART EQ E_BSIS-BLART
AND BELNR EQ E_BSIS-BELNR
AND BUDAT EQ E_BSIS-BUDAT.
IF SY-SUBRC EQ C_0.
MOVE E_BKPF-CPUDT TO E_BSIS-CPUDT.
FREE T_BKPF.
MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
TRANSPORTING CPUDT.
ENDIF.
SELECT SINGLE BUKRS
KUNNR
UMSKS
UMSKZ
AUGDT
AUGBL
ZUONR
GJAHR
BELNR
BUZEI
XREF2
FROM BSID
INTO CORRESPONDING FIELDS OF E_BSID
WHERE BUKRS EQ E_BSIS-BUKRS
AND BLART EQ E_BSIS-BLART
AND BELNR EQ E_BSIS-BELNR
AND BUDAT EQ E_BSIS-BUDAT.
IF sy-subrc EQ C_0.
DUMMY CHECK
ENDIF.
SELECT SINGLE KUNNR
FROM BSID
INTO CORRESPONDING FIELDS OF E_BSID
WHERE BUKRS EQ E_BSIS-BUKRS
AND BLART EQ E_BSIS-BLART
AND BELNR EQ E_BSIS-BELNR
AND BUDAT EQ E_BSIS-BUDAT.
IF sy-subrc EQ C_0.
DUMMY CHECK
ENDIF.
SELECT SINGLE SORTL
FROM KNA1
INTO W_SORTL
WHERE KUNNR EQ E_BSID-KUNNR.
IF SY-SUBRC EQ C_0.
MOVE W_SORTL TO E_BSIS-XREF2.
MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
TRANSPORTING XREF2.
ENDIF.
W_SGTXT = E_BSIS-SGTXT.
SPLIT W_SGTXT AT C_SLASH INTO W_SGTXT W_SGTXT1.
MOVE: W_SGTXT TO E_BSIS-SGTXT,
SY-DATUM TO E_BSIS-IDATE.
DATA : W_ZOUNR LIKE BSAS-ZUONR,
W_DATE TYPE D,
W_Z(10) TYPE C.
CLEAR: W_ZOUNR,
W_DATE,
W_Z.
MOVE E_BSIS-ZUONR TO W_ZOUNR.
MOVE : W_ZOUNR4(4) TO W_Z0(4),
W_ZOUNR2(2) TO W_Z4(2),
W_ZOUNR0(2) TO W_Z6(2).
MOVE W_Z TO W_DATE.
E_BSIS-IEDAT = E_BSIS-CPUDT - W_DATE.
CONCATENATE W_ZOUNR+0(2) C_DOT
W_ZOUNR+2(2) C_DOT
W_ZOUNR+4(4) INTO E_BSIS-ZUONR.
E_BSIS-PTIME = SY-DATUM - E_BSIS-CPUDT.
MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
TRANSPORTING IEDAT
PTIME
IDATE
SGTXT
ZUONR. "30TH
ENDLOOP.
SORT T_BSIS BY HKONT XREF2 CPUDT.
ENDFORM. " F_GET_DATA_BSIS
*& Form f_build_fld_catlog1
BUILDING FIELD CATALOG FOR OPEN ITEMS DATA
FORM F_FLD_CATLOG_OPEN_ITEMS.
ORM f_fld_catlog_open_items.
REFRESH i_catlog1.
CLEAR w_col_pos.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_HKONT
C_BSIS
w_col_pos
text-010
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_XREF2
C_BSIS
w_col_pos
text-011
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_BELNR
C_BSIS
w_col_pos
text-012
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_BLART
C_BSIS
w_col_pos
text-013
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_BLDAT
C_BSIS
W_col_pos
text-014
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_BUDAT
C_BSIS
w_col_pos
text-015
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_CPUDT
C_BSIS
w_col_pos
text-016
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_ZUONR
C_BSIS
w_col_pos
text-017
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_BSCHL
C_BSIS
w_col_pos
text-018
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_DMBTR
C_BSIS
w_col_pos
text-019
C_X "dispaly Sum Total
'40'.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_MWSKZ
C_BSIS
w_col_pos
text-020
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_SGTXT
C_BSIS
w_col_pos
text-021
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING c_IEDAT
C_BSIS
w_col_pos
text-022
SPACE
SPACE.
w_col_pos = w_col_pos + c_1.
PERFORM f_first_field_catalog USING C_PTIME
C_BSIS
w_col_pos
text-023
SPACE
SPACE.
CLEAR: W_COL_POS,
I_ALV_EVENTS.
ENDFORM. " f_fld_catlog_open_items
*& Form f_first_report_dispaly
ROUTINE FOR OPEN ITEMS GRID LAYOUT DISPLAY
FORM F_DISPALY_OPEN_ITEMS.
CLEAR W_REPNAME.
W_REPNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = W_REPNAME
I_CALLBACK_PF_STATUS_SET = C_FSTAT
I_CALLBACK_USER_COMMAND = C_FUCOM
I_CALLBACK_TOP_OF_PAGE = C_FTOPI
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 = E_ALV_LAYOUT
IT_FIELDCAT = I_CATLOG1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = C_A
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = I_ALV_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 = T_BSIS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2 .
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " f_dispaly_open_items
*& Form f_first_field_catalog
BUILDING FIELD CATALOG FOR SECONDERY LIST
-->us_fieldname field name
-->us_ref field ref field
-->us_ref tab ref table
-->us_text text
-->us_sum sum
FORM F_FIRST_FIELD_CATALOG USING US_FIELDNAME TYPE ANY
US_REF_TAB TYPE ANY
US_COL_POS TYPE ANY
US_COLTEXT TYPE ANY
US_DO_SUM TYPE ANY
us_out type any.
CLEAR E_CATLOG.
MOVE : US_FIELDNAME TO E_CATLOG-FIELDNAME,
US_REF_TAB TO E_CATLOG-TABNAME,
US_COL_POS TO E_CATLOG-COL_POS,
US_COLTEXT TO E_CATLOG-SELTEXT_L,
US_DO_SUM TO E_CATLOG-DO_SUM,
US_out to E_CATLOG-outputlen.
APPEND E_CATLOG TO I_CATLOG1.
CLEAR E_CATLOG.
APPEND E_CATLOG TO I_CATLOG1.
CLEAR E_CATLOG.
ENDFORM. " f_first_field_catalog
*& Form F_ALV_DATA_RETRIVAL
ALV DATA VALIDATION
FORM F_ALV_DATA_RETRIVAL .
IF P_OPIT EQ C_X
AND P_OSST EQ C_SPACE .
building field catlog for open items list
PERFORM f_fld_catlog_open_items.
first list display open items list
PERFORM f_dispaly_open_items.
Building Alv Layout
PERFORM f_alv_layout_open_items.
ENDIF.
Code to display only summary sheet P_OSST check box
IF P_OPIT EQ C_X
AND P_OSST EQ C_X.
building field catlog for open items Summary sheet
PERFORM F_FLD_CATLOG_SUMSHET_OPEN.
first list display open items Summary sheet
PERFORM F_DISPALY_SUMSHEET_OPEN.
ENDIF.
ENDFORM. " F_ALV_DATA_RETRIVAL
*& Form F_GET_OPEN_SUMSHET
GET SUMMARY SHEET OPEN ITEM DATA
FORM F_GET_OPEN_SUMSHET .
SORT T_BSIS BY SGTXT.
UNASSIGN <FS_BSIS>.
LOOP AT T_BSIS ASSIGNING <FS_BSIS>.
MOVE SY-TABIX TO W_TABIX.
IF W_TABIX EQ C_1.
MOVE : <FS_BSIS>-SGTXT TO W_SGTXT,
<FS_BSIS>-PTIME TO W_PTIME,
<FS_BSIS>-DMBTR TO W_DMBTR,
<FS_BSIS>-IEDAT TO W_IEDAT.
W_COUNT = W_COUNT + C_1.
CONTINUE.
ELSE.
IF <FS_BSIS>-SGTXT EQ W_SGTXT.
W_PTIME = W_PTIME + <FS_BSIS>-PTIME.
W_DMBTR = W_DMBTR + <FS_BSIS>-DMBTR.
W_COUNT = W_COUNT + C_1.
W_IEDAT = W_IEDAT + <FS_BSIS>-IEDAT.
CONTINUE .
ELSE.
W_ATIME = W_PTIME / W_COUNT.
W_IEDAT = W_IEDAT / W_COUNT.
MOVE : W_SGTXT TO E_SUMSHET_OPEN-SGTXT,
W_COUNT TO E_SUMSHET_OPEN-COUNT,
W_ATIME TO E_SUMSHET_OPEN-ATIME,
W_DMBTR TO E_SUMSHET_OPEN-DMBTR,
W_IEDAT TO E_SUMSHET_OPEN-IEDAT.
APPEND E_SUMSHET_OPEN TO T_SUMSHET_OPEN.
CLEAR: W_SGTXT,
W_PTIME,
W_DMBTR,
W_COUNT,
W_IEDAT.
MOVE : <FS_BSIS>-SGTXT TO W_SGTXT,
<FS_BSIS>-PTIME TO W_PTIME,
<FS_BSIS>-DMBTR TO W_DMBTR,
<FS_BSIS>-IEDAT TO W_IEDAT.
W_COUNT = W_COUNT + C_1.
CONTINUE.
ENDIF.
ENDIF.
ENDLOOP.
W_ATIME = W_PTIME / W_COUNT.
W_IEDAT = W_IEDAT / W_COUNT.
MOVE : W_SGTXT TO E_SUMSHET_OPEN-SGTXT,
W_COUNT TO E_SUMSHET_OPEN-COUNT,
W_ATIME TO E_SUMSHET_OPEN-ATIME,
W_DMBTR TO E_SUMSHET_OPEN-DMBTR,
W_IEDAT TO E_SUMSHET_OPEN-IEDAT.
APPEND E_SUMSHET_OPEN TO T_SUMSHET_OPEN.
CLEAR E_SUMSHET_OPEN.
ENDFORM. " F_GET_OPEN_SUMSHET
*& Form F_TOP_OF_PAGE
ITEMS TOP OF PAGE DATA
FORM F_TOP_OF_PAGE .
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE W_HEADER-INFO.
CLEAR W_HEADER.
*TITLE
MOVE C_H TO W_HEADER-TYP.
MOVE C_TEXT TO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
MOVE C_S TO W_HEADER-TYP.
MOVE C_TEXT2 TO W_HEADER-KEY.
CONCATENATE SY-DATUM+6(2) C_SLASH
SY-DATUM+4(2) C_SLASH
SY-DATUM(4) INTO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CLEAR: W_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. " F_TOP_OF_PAGE
FORM F_DISPALY_SUMSHEET_OPEN .
CLEAR w_repname.
w_repname = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = w_repname
I_CALLBACK_PF_STATUS_SET = C_FSTAT
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = C_FTOPS
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 = e_alv_layout
IT_FIELDCAT = i_catlog1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = C_A
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = i_alv_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 = T_SUMSHET_OPEN
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FREE T_SUMSHET_OPEN.
ENDFORM. " F_DISPALY_SUMSHEET_OPEN
*& Form F_TOP_OF_PAGE_SUMSHET
TOP OF PAGE FOR SUMMARY SHEET
FORM F_TOP_OF_PAGE_SUMSHET .
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE W_HEADER-INFO.
CLEAR: W_HEADER,
T_HEADER,
T_LINE.
*TITLE
MOVE C_H TO W_HEADER-TYP.
MOVE C_TEXT1 TO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. " F_TOP_OF_PAGE_SUMSHET
*& Form F_PF_STATUS
GET PF STATUS
FORM F_PF_STATUS USING US_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS C_STAT EXCLUDING US_EXTAB.
ENDFORM. "F_PF_STATUS
*& Form F_USER_COMMAND
GET USER COMMAND
*FORM F_USER_COMMAND USING W_UCOMM LIKE SY-UCOMM
US_SELFIELD TYPE SLIS_SELFIELD.
FORM F_USER_COMMAND USING US_UCOMM LIKE SY-UCOMM
US_SELFIELD TYPE SLIS_SELFIELD.
CONSTANTS:C_NEXT(6) TYPE C VALUE '&NEXT'.
if sy-subrc eq c_0.
MOVE C_TEXT3 TO US_SELFIELD-TABNAME.
endif.
IF P_OPIT EQ C_X
AND US_UCOMM EQ C_NEXT .
PERFORM F_FLD_CATLOG_SUMSHET_OPEN.
PERFORM F_DISPALY_SUMSHEET_OPEN.
ELSEIF P_CLIT EQ C_X
AND US_UCOMM EQ C_NEXT.
PERFORM F_FLD_CATLOG_SUMSHET_CLEAR.
PERFORM F_DISPALY_SUMSHET_CLEAR.
ELSEIF P_ALIT EQ C_X
AND US_UCOMM EQ C_NEXT.
PERFORM F_FLD_CATLOG_SUMSHET_TOTAL.
PERFORM F_DISPALY_SUMSHET_TOTAL.
ENDIF.
ENDFORM. "F_USER_COMMAND
*& Form f_alv_layout_open_items
text
----Hi,
Please refer to the sample code :
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
Thanks,
Sriram Ponna.
Maybe you are looking for
-
My trackpad is not working properly. It keeps highlighting everything. I went into system preferences to check the settings, but nothing there. Can someone help?
-
Issue when editing songs in "Get Info"
Hi there! I've been having this issue for quite a while now. At first I was able to deal with it, but now it's getting pretty annoying. My issue is the two options to go to the next song or previous song have dissappeared when I'm editing songs in th
-
Run Parameter Variables in Report Headings
Post Author: Jmusser CA Forum: Desktop Intelligence Reporting How do you create a Run Parameter Variable in a Report Heading for Desktop Intelligence? For example, I want to place the field "<Prev Mth End/Curr Year>" with its value in the heading of
-
Fcp crashes when importing h.264
fcp now crashes when importing h.264 (not intending to edit with it). was able to import it yesterday but not today. fcp seems to work fine otherwise. here's some of the error report if that means something to anyone. does KERN_INVALID_ADDRESS mean a
-
Hi all, I am getting below error while configuring DCOM in HFM. Can you guys help me by giving me some thoughts ? (Fri Nov 12 07:03:44 2010) Successfully set the user to DCOM limits (Fri Nov 12 07:03:44 2010) Successfully set the user to DCOM limits