Printing with ALV Grid
Hi,
I am using ALV List and ALV grid in one of my custom reports.
There is no issue with ALV List when I print the report after running the program.
But when I use ALV Grid , the report runs good and when I try to print the report I get short dump "OBJECTS_NOT_CHARLIKE" in program "LKKBLF99" of the main program "SAPLKKBL".
I am using the function module "REUSE_ALV_GRID_DISPLAY" to run the report using ALV Grid and I get the above short dump when I try to print the report.
Can anyone help me please?
Thanks,
Ashok.
Hai Ashok
Try with the following Code
*& Report ZALV_GRID *
REPORT ZALV_GRID .
TABLES: MARA.
TYPE-POOLS : SLIS.
Data declaration
DATA: BEGIN OF I_MARA OCCURS 0.
INCLUDE STRUCTURE MARA.
DATA: END OF I_MARA.
DATA: V_REPID LIKE SY-REPID.
selection-screen
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
PARAMETERS: P_MTART LIKE MARA-MTART DEFAULT 'ROH'.
SELECTION-SCREEN END OF BLOCK B1.
initialisation
INITIALIZATION.
S_MATNR-LOW = '1400'.
S_MATNR-HIGH = '1500'.
APPEND S_MATNR.
V_REPID = SY-REPID.
start-of-selection
START-OF-SELECTION.
SELECT * FROM MARA
INTO TABLE I_MARA
WHERE MATNR IN S_MATNR AND
MTART = P_MTART.
CHECK SY-SUBRC = 0.
end of selection
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'MARA'
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_MARA
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.
Thanks & Regards
Sreenivasulu P
Similar Messages
-
Issue with ALV grid print preview/spool
Hello everyone,
I am working on a report and I am having some issues with ALV grid. Currently in our DEV and QA environments the user can run the report, view the ALV grid, and print the grid without any issues.
However this isn't the case in the Prod environment. The user is able to run the report and view the grid without any issues. But when they click print preview or click print, the spool is incorrect. It shows the proper values from the grid, but the first field is reduced in length. Rather than showing a numeric field of length 10 it shows 99999999# or 99999999...
The programs are identical through every environment, including user parameters, formats, and spool settings. I have been told printing grids may have some issues, does anyone have any advice or dealt with this issue before?
I appreciate the help.
Thanks,
CI was waiting to hear from the functional team on the matter and no one has mentioned any more issues. I am assuming the problem is solved. I just noticed the thread was still un-answered and wanted to give an update.
Thank you for you help Vijay.
Regards
C -
Re: Increasing Column Header Length While Printing in ALV Grid
Hi
For some column headers in a report, the translations in Turkey are more than 40 characters, because of which while executing the report in TR language, the column header is getting truncated.
So, I would like to know if we can increase the column header length while printing the ALV Grid(OO ALV) output.
Or else, Is there any way where we can divide the column header into 2 rows.
Please let me know.
Thanks and Regards,
Vishwa.Jose and Sivaram,
Thanks for replying.
The problem we have is with the column headers, there is a limit of 40 characters for the column header in ALV reports. So, increasing the outputlen also did not help.
Regards,
Vishwa. -
I have a problem with ALV Grid User Command?
Hi Experts,
I have a problem with ALV GRID User Command.
I am calling TCODE IW33 (Order Display) from the ALV output at first time by selecting an order. But, User command is calling IW33 Initial screen with blank value of order. Even I checked in debugging the value what I selected is passing properly, but once that screen (IW33 Initial) displays, value doesn't appear. Then, Manually, I created another session and gone to TCODE IW33 and displayed an order. After that I came out from that order. Then again run my ALV program and selected another order, now order is displaying, but not what I selected current order instead of displaying previous order what I just displayed manually. If I selected any other order, system will display the same order what I dislayed manually.
Here is my code.
FORM user_command_alv USING u_ucomm TYPE sy-ucomm
us_self_field TYPE slis_selfield.
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE it_final INDEX us_self_field-tabindex INTO wa_final.
WHEN 'ORDER'.
IF NOT wa_final-order IS INITIAL.
SET PARAMETER ID 'COK' FIELD wa_final-order.
CALL TRANSACTION 'IW33' AND SKIP FIRST SCREEN.
ENDIF.
endform.
PARAMETER ID 'COK' also the standard one.
Could you please help me out, Where I did wrong?
If I select any order, that order only should display.
Thanks in advance.
Regards,
Sarayu.
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 2:33 PMhi,
Please check it once the Paramater ID is 'ANR' for IW33 order number.
Hope this may help.
Regards,
Sravanthi -
Problem with ALV grid in edit mode
Hello, gurus!
I have a problem with ALV-grid. Sometimes when I call F4 help for a cell, data is inserted in a different cell. And when I call check_changed_data method, my internal table (passed to ALV-control in set_table_for_first_display) does not updates properly. In what can be a problem?
Thanks,
MikhailHi Prabhu,
MODULE pbo_100 OUTPUT.
SET PF-STATUS 'MAIN100'.
title_of_report = text-010.
SET TITLEBAR '0100' WITH title_of_report.
DATA: g_event_receiver TYPE REF TO lcl_event_handler.
IF z_custom_container IS INITIAL .
CREATE OBJECT z_custom_container
EXPORTING
container_name = 'ALV_ZAC'.
CREATE OBJECT alv_grid
EXPORTING
i_parent = z_custom_container.
g_repid = sy-repid.
gs_variant-report = g_repid.
x_save = 'A'.
PERFORM check_alv_grid_fields.
ps_layout-cwidth_opt = 'X'.
ps_layout-edit = 'X'.
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = '1'.
* CALL METHOD alv_grid->register_edit_event
* EXPORTING
* i_event_id = cl_gui_alv_grid=>mc_evt_enter.
APPEND s_list_rec to it_list_rec.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = ps_layout
is_variant = gs_variant
i_save = x_save
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = it_list_rec[].
CALL METHOD alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDIF.
FORM check_alv_grid_fields .
DATA: ls_fcat LIKE LINE OF pt_fieldcat.
REFRESH pt_fieldcat .
CLEAR: ps_layout, ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-ref_field = 'VBELN'. ls_fcat-ref_table = 'LIPS'. " .
ls_fcat-outputlen = 9.
* ls_fcat-datatype = 'CHAR'.
* ls_fcat-inttype = 'C'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR: ls_fcat.
ls_fcat-fieldname = 'ERDAT'.
ls_fcat-ref_field = 'ERDAT'. ls_fcat-ref_table = 'LIPS'.
ls_fcat-outputlen = 9.
* ls_fcat-f4availabl = 'X' .
* ls_fcat-datatype = 'DATS'.
* ls_fcat-inttype = 'D'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR: ls_fcat.
ENDFORM. " check_alv_grid_fields
FORM save_p .
CLEAR l_valid.
CALL METHOD alv_grid->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid IS INITIAL.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-i01
txt1 = text-i02
txt2 = text-i03
txt3 = text-i04.
ELSE.
i_dat_reg = zrumm_prr-cdprr.
CLEAR is_temp_otc.
freshit i_prrpus_fax.
freshit i_list2_ot.
LOOP AT it_list_rec INTO s_list_rec.
MOVE-CORRESPONDING s_list_rec TO i_list2_ot.
i_list2_ot-fgrup = 'RECE'.
i_list2_ot-prrnu = i_num_prr.
APPEND i_list2_ot.
MOVE-CORRESPONDING s_list_rec TO i_prrpus_fax.
APPEND i_prrpus_fax.
ENDLOOP.
ENDIF.
Edited by: Mikhail Sarychev on Mar 16, 2011 6:41 AM
Edited by: Mikhail Sarychev on Mar 16, 2011 6:49 AM
Edited by: Mikhail Sarychev on Mar 16, 2011 6:49 AM -
Handling Double click on a Pop-up screen with ALV Grid
Hello Experts,
I have an issue handling double click on ALV Pop-up screen. I tried to achive this using following steps.
1. I defined a local class in Top-include to handle double click and implemented it in the following way.
CLASS lcl_alv_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
on_double_click FOR EVENT double_click
OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no.
ENDCLASS. "lcl_alv_event_handler DEFINITION
*~~~ Implementation code
CLASS lcl_alv_event_handler IMPLEMENTATION.
To handle Selection of Issue data on Screen 100
METHOD on_double_click.
DATA: lt_row_no TYPE lvc_t_roid,
ls_req TYPE zcst_zirt_seltab.
READ TABLE gt_req
INTO ls_req
INDEX e_row-index.
g_req_id = ls_req-zzrequest_id.
gv_selected = true.
CALL METHOD go_alv->dispatch
EXPORTING
cargo = 'OK'
eventid = 3
is_shellevent = ' '
is_systemdispatch = 'X'
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.
ENDMETHOD. "on_double_click
ENDCLASS. "lcl_alv_event_handler IMPLEMENTATION
2. Registered the event in the PBO module of the screen
ls_events-eventid = 3.
ls_events-appl_event = gc_true.
APPEND ls_events TO lt_events.
CALL METHOD co_alv->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 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.
CREATE OBJECT co_alv_event_handler.
SET HANDLER: co_alv_event_handler->on_double_click FOR co_alv.
CALL METHOD co_alv->set_toolbar_interactive.
3. In the PAI module of Screen, tried to handle the event 'OK' that waqs registred in PBO.
CASE save_ok.
WHEN 'OK'.
Get selected line
CALL METHOD io_alv->get_selected_rows
IMPORTING
et_index_rows = lt_rows
et_row_no = lt_rows_no.
IF NOT lt_rows IS INITIAL.
READ TABLE lt_rows INTO ls_rows INDEX 1.
IF sy-subrc EQ 0.
gv_selected = 'X'.
READ TABLE it_req
INTO ls_req
INDEX ls_rows-index.
e_req_id = ls_req-zzrequest_id.
SET SCREEN 0.
ENDIF.
ELSE.
SET SCREEN 0.
ENDIF.
With this code what is happening is, when user double clicks a line on Pop-up screen with ALV grid data, the program is able to successfully get into the class implementation but the control is not going to PAI module to execute the OK_code handling part.
Am I doing this in the right way? Appreciate quick suggestions. Proper posts will be thoroughly awarded with points.
Thx.
MinniPut your code into the Event handler Implementation of Double Click which is there in the PAI Module.
Regards,
Naimesh Patel -
Display 2 rows per entry with ALV Grid
Hi Experts,
I need to display the results of a report with ALV Grid. The Problem is: I need to display the resultdata (some numbers etc..) in one row and then add a second row with the longtext.
The ALV should look somthing like this:
resultdata1 resultdata2 resultdata3
longtext1
resultdata1 resultdata2 resultdata3
longtext1
resultdata1 resultdata2 resultdata3
longtext1
Can anyone of you give me hint on how to do that?
(The row_pos and col_pos ind the fieldcat do not do the trick )
Thanx
Felixhi ,
You can do this
resultdata1 resultdata2 resultdata3
longtext1
resultdata1 resultdata2 resultdata3
longtext1
resultdata1 resultdata2 resultdata3
longtext1
Create two internal table .
one for : resultdata1 resultdata2 resultdata3
second for longtext1
see that both tables have matching primary key .
then can match the data and append in another third table .
regards
Deepak. -
GL Account analysis report with ALV Grid control
Hi Everyone,
I am looking for a GL Account analysis report with ALV Grid Control.
Can I get sample code for this report.
Thank you
PrasadHi Rob,
Actually, I am searching for a Report which gives GL account analysis.
If anybody can throw more light on this ...it would be great.
Which Tables and fields i should refer for this report.
Thanks -
Splitter container with alv grid has to be replaced with a dynpro
I have a container which I have splitt in 4 areas, on the right half I have two splitter container with alv grids.
On the left side I have my navigation tree in 2 splitter container.
I don't know if this really works, but is it possible that I call a dynpro in the splitter container (after using my navigation tree) where still my alv grids exist?so it is not able that I can show a dynpro with several text fields?
or can I introduce the textfields in another version to the container?
In se80 I think you have the same, there they call another transactions, is it possible that I call a transaction to the right side of a splitter container? -
How to print multiple ALV Grids with only one print dialog?
Hi,
I have a report that has multiple ALV grids in splitter containers. The users want to be able to print those ALVs by pushing only one print button. I got it to work (parameter IS_PRINT and method SET_FRONTEND_PRINT before calling SET_TABLE_FOR_FIRST_DISPLAY) but I can't find a way to avoid that the printer dialog pops up for every grid I print.
I tried to use the function module approach with REUSE_ALV_LIST_DISPLAY but have the same issue. Any thoughts?
Thanks,
GuentherHi Peluka,
Well, that's exactly what I am doing. Putting one central button in the app is not the problem; the issue is that the print dialog (to select the printer) pops up for every individual ALV grid. E.g. if I place 4 ALV grids on my screen and trigger their print from a central button, I am getting 4 print dialogs.
Cheers,
Guenther -
Hi,
I'm using OO for ALV-GRID. I have problems by using TOP_OF_PAGE.
I try it like this:
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
HANDLE_TOP_OF_PAGE
FOR EVENT TOP_OF_PAGE OF CL_GUI_ALV_GRID,
HANDLE_PRINT_TOP_OF_PAGE
FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID.
ENDCLASS. "LCL_EVENT_HANDLER DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
*--Handle Print Top of page
METHOD HANDLE_PRINT_TOP_OF_PAGE.
IF SY-PAGNO = 1.
PERFORM PRINT_TOP_OF_PAGE.
ENDIF.
ENDMETHOD. "handle_print_top_of_page
*--Handle Top of page
METHOD HANDLE_TOP_OF_PAGE.
PERFORM TOP_OF_PAGE.
ENDMETHOD. "handle_top_of_page
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
CREATE OBJECT GR_EVENT_HANDLER.
SET HANDLER GR_EVENT_HANDLER->HANDLE_PRINT_TOP_OF_PAGE FOR GR_ALVGRID.
SET HANDLER GR_EVENT_HANDLER->HANDLE_TOP_OF_PAGE FOR GR_ALVGRID.
FORM PRINT_TOP_OF_PAGE.
WRITE: / 'Print-Header'.
ENDFORM. "print_top_of_page
FORM TOP_OF_PAGE.
WRITE: / 'Screnn-Header'.
ENDFORM. "top_of_page
Has anyone an idea what i shell do??
Thanks
regards, DieterHi Vijay,
i have tried this code (same as you but with MARA).
I created PF-Staus STATUS und screen 100 with container CONTROL
but i don't get any result (IT_MARA has 20 entries).
Which mistake have i done?
REPORT ZGRO_TEST1 MESSAGE-ID ZZ .
DATA: IT_MARA TYPE TABLE OF MARA.
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM.
DATA: G_CONTAINER TYPE SCRFNAME VALUE 'CONTROL',
O_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT,
O_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
O_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER,
O_PARENT_TOP TYPE REF TO CL_GUI_CONTAINER,
O_HTML_CNTRL TYPE REF TO CL_GUI_HTML_VIEWER.
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
*Event Handler for Top of page
TOP_OF_PAGE FOR EVENT TOP_OF_PAGE
OF CL_GUI_ALV_GRID
IMPORTING E_DYNDOC_ID.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD TOP_OF_PAGE.
Top-of-page event
PERFORM EVENT_TOP_OF_PAGE USING O_DYNDOC_ID.
ENDMETHOD. "top_of_page
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
START-OF-SELECTION.
SELECT *
FROM MARA
UP TO 20 ROWS
INTO TABLE IT_MARA.
END-OF-SELECTION.
IF NOT IT_MARA[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
SET TITLEBAR 'TITLE'.
IF G_CUSTOM_CONTAINER IS INITIAL.
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
FORM CREATE_AND_INIT_ALV .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER.
Create TOP-Document
CREATE OBJECT O_DYNDOC_ID
EXPORTING STYLE = 'ALV_GRID'.
Create Splitter for custom_container
CREATE OBJECT O_SPLITTER
EXPORTING PARENT = G_CUSTOM_CONTAINER
ROWS = 2
COLUMNS = 1.
CALL METHOD O_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = O_PARENT_TOP.
CALL METHOD O_SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = O_PARENT_GRID.
Set height for g_parent_html
CALL METHOD O_SPLITTER->SET_ROW_HEIGHT
EXPORTING
ID = 1
HEIGHT = 5.
CREATE OBJECT G_GRID
EXPORTING I_PARENT = O_PARENT_GRID.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
*Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'MARA'
CHANGING
IT_OUTTAB = IT_MARA[].
CALL METHOD O_DYNDOC_ID->INITIALIZE_DOCUMENT
EXPORTING
BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.
Processing events
CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = O_DYNDOC_ID.
ENDFORM. "CREATE_AND_INIT_ALV
FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
DATA : DL_TEXT(255) TYPE C. "Text
CALL METHOD DG_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = 'Flight Details'
SAP_STYLE = CL_DD_AREA=>HEADING
SAP_FONTSIZE = CL_DD_AREA=>LARGE
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CALL METHOD DG_DYNDOC_ID->ADD_GAP
EXPORTING
WIDTH = 200.
CALL METHOD O_DYNDOC_ID->ADD_PICTURE
EXPORTING
PICTURE_ID = 'ENJOYSAP_LOGO'.
Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
program ID
DL_TEXT = 'Program Name :'.
CALL METHOD DG_DYNDOC_ID->ADD_GAP.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CLEAR DL_TEXT.
DL_TEXT = SY-REPID.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
CLEAR : DL_TEXT.
program ID
DL_TEXT = 'User Name :'.
CALL METHOD DG_DYNDOC_ID->ADD_GAP.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CLEAR DL_TEXT.
DL_TEXT = SY-UNAME.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
Run Date
DL_TEXT = 'Run Date :'.
CALL METHOD DG_DYNDOC_ID->ADD_GAP.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CLEAR DL_TEXT.
Move date
WRITE SY-DATUM TO DL_TEXT.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
CLEAR : DL_TEXT.
*Time
DL_TEXT = 'Time :'.
CALL METHOD DG_DYNDOC_ID->ADD_GAP.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.
CLEAR DL_TEXT.
Move time
WRITE SY-UZEIT TO DL_TEXT.
CALL METHOD O_DYNDOC_ID->ADD_TEXT
EXPORTING
TEXT = DL_TEXT
SAP_EMPHASIS = CL_DD_AREA=>HEADING
SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.
Add new-line
CALL METHOD DG_DYNDOC_ID->NEW_LINE.
PERFORM DISPLAY.
ENDFORM. " EVENT_TOP_OF_PAGE
FORM DISPLAY.
Creating html control
IF O_HTML_CNTRL IS INITIAL.
CREATE OBJECT O_HTML_CNTRL
EXPORTING
PARENT = O_PARENT_TOP.
ENDIF.
CALL METHOD O_DYNDOC_ID->MERGE_DOCUMENT.
O_DYNDOC_ID->HTML_CONTROL = O_HTML_CNTRL.
Display document
CALL METHOD O_DYNDOC_ID->DISPLAY_DOCUMENT
EXPORTING
REUSE_CONTROL = 'X'
PARENT = O_PARENT_TOP
EXCEPTIONS
HTML_DISPLAY_ERROR = 1.
IF SY-SUBRC NE 0.
MESSAGE I999 WITH 'Error in displaying top-of-page'(036).
ENDIF.
ENDFORM. " display
Regards, Dieter -
How to display more than 255 chars in background job with ALV Grid ????
Hi All,
I am using ALV grid with OO.
I have used call screen for ALV grid display. I have to display more than 255 characters in width. While running it, I can see the list perfectly.
But in background mode, the list is truncated after 255 chars.
Can anybody help how to send complete list(width more than 255 chars) to spool.
Thanks and Regards,
NehaHi SAP fan,
<b>YES you can run the ALV report in background mode.
To run the report in background do F9 instead of F8, then give immediate and save.
Now goto Sm35 goto job overview and view the job listed
Choose the job and press the spool button. It will show the list created on the next page. When u clcik the list u can see the ALV output.
To see this the job should be in the finished status.
How to define Periodic Jobs
1.Execute transaction SM36
2.Define Job name, Job class, Target server
3.Click on 'START CONDITION' button
4.Click on 'Date/Time' button
5.Enter Scheduled start DATE & TIME. Check mark 'Periodic Job' field. Click on 'Period values' button and select 'Hourly' or 'Dialy' or 'Weekly' or 'Monthly' or Other period and SAVE. Go back to main screen.
6.Click on 'STEPS' button and enter Program name and Variant under box 'ABAP Program'. Click on 'Print Specification' button and enter Printer name under 'Output device' and SAVE
7.Click on SAVE button until you get message on bottom of the screen that describes 'Job XYZ saved with status: Scheduled'.
8.Click on 'Job overview' button or execute SM37 transaction.
9.Select the appropriate 'Job name', 'User name', 'Job Status' & Schedule date under 'Job start condition' and click on 'Execute' button or press F8.
10.You will now see all your scheduled JOBS.
<b>Case: 2</b>
You can Run in Background but make sure it is alv list, not alv Grid FM. if you are uisng alv list not problem , but if you are using alv grid then you can code like this..
if sy-batch = ' '.
call 'REUSE_ALV_GRID_DISPLAY'.
else.
call 'REUSE_ALV_LIST_DISPLAY'.
endif.
if you are using OO alv then write this code..
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING e_offline = off.
IF off IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
ENDIF.
<b>Case: 3</b>
if you are using OO ALV.
Just before creating the custom container check for the following condition.
Batch or Web Reporting
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
CREATE OBJECT o_custcontainer
EXPORTING
container_name = lc_custcontrol
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
ENDIF.
You can see the output in Spool in transaction SP01.</b>
Good Luck and thanks
AK -
Hi,
I am working an ALV grid in my report. after executing my report ALV grid is displaying all columns with all records. But if i am trying to see print priview or if i am trying to do export to spreadsheet, many columns are missing & records also jumbling from their exact places.
Why it is coming like this? can u help me. .
Thanks
vishnuHi,
if i am trying to do export to spreadsheet, many columns are missing & records also jumbling from their exact places.
Regarding on your query, You will write a query as select query
I.e.., select a query corresponding coloumns and reterive the data
Then check through an select corresponding coloums
Then solved your problem.
Regards,
Sekhar -
Hello All,
I want to print data on an alv grid to spool according the current layout using code.
Can anyone give me suggestion, maybe some sample code?
Thanks in advance,
AlexHi,
I have 2 ALV grid in the screen and pront to spool of both ALV's using OOp.
Please find sample code. Whenever report runs in the background i simply call this print subroutine after creating fieldcatalog, layout, sorting table etc.
FORM list_append TABLES ut_table
USING u_no TYPE char1
u_tabname TYPE slis_tabname.
IF u_no CA '13'.
MOVE 'TOP_OF_PAGE' TO ls_event-name.
CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
APPEND ls_event TO lt_events.
ELSE.
MOVE 'TOP_OF_LIST' TO ls_event-name.
CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
it_fieldcat = lt_fieldcat
is_layout = ls_layout
i_tabname = u_tabname
it_events = lt_events
it_sort = lt_sort
* i_text =
TABLES
t_outtab = ut_table
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.
ENDFORM. " LIST_APPEND
* Form f_list_display
FORM f_list_display.
DATA ls_print TYPE slis_print_alv.
ls_print-no_print_selinfos = 'X'. " Display no selection infos
ls_print-no_print_listinfos = 'X'. " Display no listinfos
ls_print-reserve_lines = 2. " Lines reserved for end of page
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
is_print = ls_print
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. " F_LIST_DISPLAY
May this will help you.
aRs
Message was edited by:
aRs -
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.
Maybe you are looking for
-
Error while selecting from sequence
Hi, select seq_empid.nextval from dual; when selecting this from Java code it is giving error "table or view does not exist".. can anybody pls guide me as to what possible reasons could be for the error? thx
-
i am desparately seeking the elusive 9.5.1 rom. If anyone can help, my email is [email protected] Thanks
-
Upgrading from 4.2 to 5.1 Performance Issues
Hi All, We are finally upgrading from 4.2 to 5.1. Both our 4.2 and 5.1 servers are identical, however, we are noticing major performance issues in one of our applications that contains 7 account hierarchies and 4 entity hierarchies. Creating a simple
-
WebService in Adobe Forms in Test and Production Systems
Hello Friends, I am facing a peculiar problem with the webservice. I have created one Adobe Form in Development system and in that Adobe Form I used one WebService to get the User's Complete Name. Its working fine in Development System. And all the W
-
Installing Forms and Reports 6i
Can Forms and Reports 6i be used with Oracle 8i Ver 8.1.5 also can the default home directory be the same as 8i. I receive an error message stating that I can't and was wondering if the two programs are compatible.