| Michael's profileAt world's endBlogGuestbookNetwork | Help |
|
|
March 28 Get SAP data and mail mail merge it to a MS word document************************************************************************ March 11 Buttons to display First, Prev. Next, Last recordsCode: REPORT z_alv_grid_ctrl_refresh_2. Displaying ALV Grid in Background JobDisplaying ALV Grid in Background Job Code: *&---------------------------------------------------------------------* A new approach to ALV ProgrammingA new approach to ALV Programming Code: REPORT ZALV_OBJECTMODEL_TEST. We shall first create an internal table dynamically (this technique has already been discussed in some of the earlier weblogs) and populate it with the data from the table SPFLI. Code: START-OF-SELECTION. Now all you have to do is to call a method of the class CL_SALV_TABLE to display your grid. Code: * Instead of if_salv_c_bool_sap=>false, you can pass the Further information about the ALV Object Model is available on the SAP Online Documentation ALV Grid List with page breakREPORT z_demo_alv_sort_2. Docking container with Text Editor and GridYou may be able to use a text editor container directly above the ALV grid. Implement this program which I just developed, and run it. See how the text is in a text editor control above the ALV. Maybe you could use this. I have implemented in a docking container, so that you have a working(cut/paste) solution. You could easily modify to implement this in a dynpro container. Code: report zrich_0001 . A Form that gets and sets user parameters.*----------------------------------------------------------------------*
* FORM GET_USER_PARAM
*----------------------------------------------------------------------*
* Gets a user parameter
*----------------------------------------------------------------------*
FORM get_user_param CHANGING p_value TYPE c.
DATA: lv_param_value TYPE xuvalue.
CALL FUNCTION 'G_GET_USER_PARAMETER'
EXPORTING
parameter_id = 'NDR'
IMPORTING
parameter_value = lv_param_value.
MOVE lv_param_value TO p_value.
ENDFORM. "get_print_param
*----------------------------------------------------------------------*
* FORM SET_USER_PARAM
*----------------------------------------------------------------------*
* Sets the value of a user parameter
*----------------------------------------------------------------------*
FORM set_user_param USING p_value TYPE c.
DATA: lv_param_value TYPE xuvalue.
CLEAR lv_param_value.
MOVE p_value TO lv_param_value.
CALL FUNCTION 'G_SET_USER_PARAMETER'
EXPORTING
parameter_id = 'NDR'
parameter_value = lv_param_value.
ENDFORM. "set_print_param Removes the confirmation flag from a transfer order and all its items.*---------------------------------------------------------------------- * Program Name: Z_TRANSFER_ORDER_UNCONFIRM * Author : Michael * Description : Removes the confirmation flag from a transfer order * and all its items *---------------------------------------------------------------------- REPORT Z_TRANSFER_ORDER_UNCONFIRM. PARAMETERS: p_order TYPE LTAP-TANUM. TABLES LTAP. TABLES LTAK. *items SELECT * FROM LTAP WHERE TANUM = p_order. LTAP-PQUIT = SPACE. MODIFY LTAP. ENDSELECT. *order SELECT * FROM LTAK WHERE TANUM = p_order. LTAK-KQUIT = SPACE. MODIFY LTAK. ENDSELECT. Write: 'Done'. Generates a dynamic program that allows you to download data from a table, with specified download and selection fields.***********************************************************************************************************
* Program: Z_TABLE_DATA_DOWNLOAD
* Restrictions: -Should be run in the background, for large tables
* -If run in production, should be run after business hours, as it could cause system
* performance issues
* Description: Given the name of a database table, a program is generated that allows the user to enter
* values for each field in the table. When the generated report is run, the contents of the
* table are downloaded to a unix file.
*
* The user is prompt to choose the fields to appear on the selection screen of the program
* (up to 40 fields) and the fields to write to the downloaded file.
*
* The generated program can be run in the background, via the Program menu on the selection
* screen of the generated program.
***********************************************************************************************************
REPORT z_table_data_download MESSAGE-ID zbc_o.
***********************************************************************************************************
* VARIABLES
***********************************************************************************************************
*** Data
DATA:
v_report_name(30) TYPE c VALUE 'ZBC_O_TABLE_DATA_DOWNLOAD_GEN',
v_back_to_start(1) TYPE c,
v_ok_code TYPE sy-ucomm. "ok code from the screens
*** Screen
CONTROLS:
i_popup_table TYPE TABLEVIEW USING SCREEN 2000.
*** Internal Tables
TYPES:
BEGIN OF t_fields,
fieldname TYPE dd03l-fieldname,
position TYPE dd03l-position,
screen(1) TYPE c, " show on the selection screen
download(1) TYPE c, " download to the file
END OF t_fields.
DATA:
i_fields TYPE STANDARD TABLE OF t_fields,
v_fields TYPE t_fields.
DATA:
i_source TYPE STANDARD TABLE OF char72.
* CHECK FOR AUTHORIZATION
INCLUDE: zbc_o_modify_sap_table_check.
***********************************************************************************************************
* SELECTION SCREEN
***********************************************************************************************************
PARAMETERS:
p_table TYPE dd02l-tabname OBLIGATORY MEMORY ID tbl, "#EC EXISTS
p_file TYPE rlgrap-filename OBLIGATORY DEFAULT '/usr/sap/OSD/local/downloads/table.txt'.
***********************************************************************************************************
* START-OF-SELECTION
***********************************************************************************************************
START-OF-SELECTION.
CLEAR:
v_back_to_start.
PERFORM get_table_fields.
IF i_fields IS INITIAL.
MESSAGE e037.
ELSE.
PERFORM select_table_fields.
IF v_back_to_start = 'X'.
CLEAR:
v_back_to_start.
ELSE.
PERFORM generate_selection_program.
ENDIF.
ENDIF.
***********************************************************************************************************
* FORM GET_TABLE_FIELDS
***********************************************************************************************************
* [+] Checks that the table exists, and is the correct type of table (transparent, cluster, or pool)
* [+] Gets the fields of the table
***********************************************************************************************************
FORM get_table_fields.
TABLES:
dd02l. "#EC NEEDED
CLEAR:
i_fields.
REFRESH:
i_fields.
* check that the table type is legit.
SELECT *
FROM dd02l
WHERE tabname = p_table
AND
( tabclass = 'TRANSP' OR
tabclass = 'CLUSTER' OR
tabclass = 'POOL' ) .
EXIT.
ENDSELECT.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* now get the fields
SELECT fieldname position
FROM dd03l
INTO CORRESPONDING FIELDS OF TABLE i_fields
WHERE tabname = p_table.
SORT i_fields BY position.
* Deletes any .INCLUDE and similar statements
DELETE i_fields WHERE fieldname+0(1) = '.'.
ENDFORM. "get_table_fields
***********************************************************************************************************
* FORMM SELECT_TABLE_FIELDS
***********************************************************************************************************
* [+] Asks the user to select the fields for the selection screen and the download file
***********************************************************************************************************
FORM select_table_fields.
CALL SCREEN 2000 STARTING AT 1 1.
ENDFORM. "select_table_fields
***********************************************************************************************************
* FORM GENERATE_SELECTION_PROGRAM
***********************************************************************************************************
* [+] Generates the program that performs the downloading and selection from the database
***********************************************************************************************************
FORM generate_selection_program.
DATA:
lv_line(72) TYPE c,
lv_index(3) TYPE c,
lv_table(31) TYPE c,
lv_selscr_key(8) TYPE c,
lv_more_than_one(1) TYPE c.
DATA:
lv_textpool TYPE textpool,
li_textpool TYPE STANDARD TABLE OF textpool.
CLEAR:
lv_table,
li_textpool.
WRITE p_table TO lv_table+1.
* Setting up the variables
PERFORM build_selection_program USING: 'REPORT temp.'.
PERFORM build_selection_program USING: 'DATA: li_select_table LIKE STANDARD TABLE OF'.
CLEAR: lv_line.
CONCATENATE lv_table '.' INTO lv_line.
PERFORM build_selection_program USING: lv_line.
PERFORM build_selection_program USING: 'DATA: lv_select_table LIKE'.
CLEAR: lv_line.
CONCATENATE lv_table '.' INTO lv_line.
PERFORM build_selection_program USING: lv_line.
PERFORM build_selection_program USING: 'DATA: lv_field_char(1000) TYPE c.'.
PERFORM build_selection_program USING: 'DATA: lv_offset TYPE i.'.
PERFORM build_selection_program USING: 'CONSTANTS: c_linebreak(1) TYPE x VALUE ''0D''.'.
PERFORM build_selection_program USING: 'CONSTANTS: c_tab(1) TYPE x VALUE ''09''.'.
CLEAR: lv_line.
CONCATENATE 'TABLES: ' lv_table '.' INTO lv_line.
PERFORM build_selection_program USING: lv_line.
* Creating the select-options
LOOP AT i_fields INTO v_fields WHERE screen = 'X'.
CLEAR:
lv_line,
lv_index,
lv_selscr_key.
WRITE sy-tabix TO lv_index LEFT-JUSTIFIED.
CONCATENATE 'SELECT-OPTIONS: s_fld' lv_index ' FOR ' lv_table '-' v_fields-fieldname '.' INTO lv_line.
PERFORM build_selection_program USING: lv_line.
CONCATENATE 's_fld' lv_index INTO lv_selscr_key.
* Adds the name for the select-option into the text elements
lv_textpool-id = 'S'.
lv_textpool-key = lv_selscr_key.
lv_textpool-entry = 'D'. "means to get the name from the dictionary
TRANSLATE lv_textpool-key TO UPPER CASE. "#EC SYNTCHAR
APPEND lv_textpool TO li_textpool.
ENDLOOP.
DATA:
lv_file(130) TYPE c.
CONCATENATE '''' p_file '''' INTO lv_file.
* Open the file
PERFORM build_selection_program USING: 'OPEN DATASET ', lv_file, ' FOR OUTPUT IN BINARY MODE.'.
* insert the row headers
CLEAR:
lv_more_than_one.
LOOP AT i_fields INTO v_fields WHERE download = 'X'.
CLEAR:
lv_line,
lv_index.
WRITE sy-tabix TO lv_index LEFT-JUSTIFIED.
IF lv_more_than_one = 'X'.
PERFORM build_selection_program USING: 'TRANSFER c_tab TO ', lv_file, '.'.
ENDIF.
CONCATENATE 'TRANSFER ''' v_fields-fieldname ''' TO ' INTO lv_line.
PERFORM build_selection_program USING: lv_line, lv_file, '.'.
lv_more_than_one = 'X'.
ENDLOOP.
PERFORM build_selection_program USING: 'TRANSFER c_linebreak TO ', lv_file, '.'.
* Create the SELECT statement
CLEAR: lv_line.
CONCATENATE 'SELECT * FROM ' lv_table INTO lv_line.
PERFORM build_selection_program USING: lv_line.
READ TABLE i_fields INTO v_fields WITH KEY fieldname = 'MANDT' screen = 'X'.
IF sy-subrc = 0.
* mandt is specified - the user will specify the system mandt to use
PERFORM build_selection_program USING: 'CLIENT SPECIFIED INTO TABLE li_select_table PACKAGE SIZE 1000 WHERE'.
ELSE.
* mandt is not specified - so use the system mandt
PERFORM build_selection_program USING: 'INTO TABLE li_select_table PACKAGE SIZE 1000 WHERE'.
ENDIF.
* insert the select-options into the SELECT statement
CLEAR:
lv_more_than_one.
LOOP AT i_fields INTO v_fields WHERE screen = 'X'.
CLEAR:
lv_line,
lv_index.
WRITE sy-tabix TO lv_index LEFT-JUSTIFIED.
IF lv_more_than_one = 'X'.
PERFORM build_selection_program USING: 'AND'.
ENDIF.
PERFORM build_selection_program USING: v_fields-fieldname.
CONCATENATE 'IN s_fld' lv_index INTO lv_line.
PERFORM build_selection_program USING: lv_line.
lv_more_than_one = 'X'.
ENDLOOP.
PERFORM build_selection_program USING: '.'. "dot at the end of the SELECT
* loop over the data, appending to the file.
PERFORM build_selection_program USING: 'LOOP AT li_select_table INTO lv_select_table.'.
* insert the select-options into the output loop
CLEAR:
lv_more_than_one.
LOOP AT i_fields INTO v_fields WHERE download = 'X'.
CLEAR:
lv_line,
lv_index.
WRITE sy-tabix TO lv_index LEFT-JUSTIFIED.
IF lv_more_than_one = 'X'.
PERFORM build_selection_program USING: 'TRANSFER c_tab TO ', lv_file, '.'.
ENDIF.
CONCATENATE 'WRITE: lv_select_table-' v_fields-fieldname INTO lv_line.
PERFORM build_selection_program USING: lv_line, 'TO lv_field_char LEFT-JUSTIFIED.'.
PERFORM build_selection_program USING: 'lv_offset = STRLEN( lv_field_char ).'.
PERFORM build_selection_program USING: 'TRANSFER lv_field_char TO ', lv_file, ' LENGTH lv_offset.'.
lv_more_than_one = 'X'.
ENDLOOP.
PERFORM build_selection_program USING: 'TRANSFER c_linebreak TO ', lv_file, '.'.
PERFORM build_selection_program USING: 'ENDLOOP.'.
* ENDSELECT because PACKAGE SIZZE was specified, creating a loop.
PERFORM build_selection_program USING: 'ENDSELECT.'.
* close the file
PERFORM build_selection_program USING: 'CLOSE DATASET ', lv_file, '.'.
PERFORM build_selection_program USING: 'WRITE: / ''Download has completed.''.'.
* Save the report
DELETE REPORT v_report_name.
INSERT REPORT v_report_name FROM i_source.
GENERATE REPORT v_report_name.
* Save the text elements
INSERT textpool v_report_name FROM li_textpool LANGUAGE sy-langu.
* Run the report
SUBMIT (v_report_name) VIA SELECTION-SCREEN AND RETURN.
ENDFORM. "generate_selection_program
***********************************************************************************************************
* FORM BUILD_SELECTION_PROGRAM
***********************************************************************************************************
* [+] Adds the p_code text to the source code of the generated program
***********************************************************************************************************
FORM build_selection_program
USING
p_code TYPE c.
APPEND p_code TO i_source.
ENDFORM. "build_selection_program
***********************************************************************************************************
* FORM SELECT_ALL_SCREEN
***********************************************************************************************************
* [+] Selects all the 'screen' checkboxes on the popup
***********************************************************************************************************
FORM select_all_screen.
LOOP AT i_fields INTO v_fields.
v_fields-screen = 'X'.
MODIFY i_fields FROM v_fields.
ENDLOOP.
ENDFORM. "select_all_screen
***********************************************************************************************************
* FORM SELECT_ALL_DOWNLOAD
***********************************************************************************************************
* [+] Selects all the 'download' checkboxes on the popup
***********************************************************************************************************
FORM select_all_download.
LOOP AT i_fields INTO v_fields.
v_fields-download = 'X'.
MODIFY i_fields FROM v_fields.
ENDLOOP.
ENDFORM. "select_all_download
***********************************************************************************************************
* FORM SELECT_NONE_SCREEN
***********************************************************************************************************
* [+] Deselects all the 'screen' checkboxes on the popup
***********************************************************************************************************
FORM select_none_screen.
LOOP AT i_fields INTO v_fields.
v_fields-screen = ' '.
MODIFY i_fields FROM v_fields.
ENDLOOP.
ENDFORM. "select_none_screen
***********************************************************************************************************
* FORM SELECT_NONE_DOWNLOAD
***********************************************************************************************************
* [+] Deselects all the 'download' checkboxes on the popup
***********************************************************************************************************
FORM select_none_download.
LOOP AT i_fields INTO v_fields.
v_fields-download = ' '.
MODIFY i_fields FROM v_fields.
ENDLOOP.
ENDFORM. "select_none_download
***********************************************************************************************************
* MODULE SET_FIELDS_2000
***********************************************************************************************************
* [+] Sets the field values on the popup
***********************************************************************************************************
MODULE set_fields_2000 OUTPUT. "#EC NEEDED
ENDMODULE. " set_fields_2000 OUTPUT
***********************************************************************************************************
* MODULE SET_STATUS_2000
***********************************************************************************************************
* [+] Sets the status of the popup, to alllow for function codes
***********************************************************************************************************
MODULE set_status_2000 OUTPUT.
SET PF-STATUS 'POPUP'.
ENDMODULE. " set_status_2000 OUTPUT
***********************************************************************************************************
* MODULE UPDATE_CHECKBOXES_2000
***********************************************************************************************************
* [+] Saves the selected checkboxes from the popup back to the source table
***********************************************************************************************************
MODULE update_checkboxes_2000 INPUT.
DATA:
lv_temp_fields LIKE v_fields. "#EC NEEDED
IF v_ok_code = 'OK' OR v_ok_code = space.
READ TABLE i_fields
INTO lv_temp_fields
WITH KEY fieldname = v_fields-fieldname.
IF sy-subrc = 0.
MODIFY i_fields FROM v_fields INDEX sy-tabix.
ENDIF.
ENDIF.
ENDMODULE. " update_checkboxes_2000 INPUT
***********************************************************************************************************
* MODULE PROCESS_BUTTONS_2000
***********************************************************************************************************
* [+] Processes the function codes from the popup
***********************************************************************************************************
MODULE process_buttons_2000 INPUT.
DATA:
lv_num_screen TYPE i,
lv_ok_code LIKE v_ok_code.
CLEAR:
lv_num_screen.
lv_ok_code = v_ok_code.
IF NOT lv_ok_code IS INITIAL.
CLEAR:
v_ok_code.
IF lv_ok_code = 'ALL_S'.
PERFORM select_all_screen.
ELSEIF lv_ok_code = 'ALL_D'.
PERFORM select_all_download.
ELSEIF lv_ok_code = 'NONE_S'.
PERFORM select_none_screen.
ELSEIF lv_ok_code = 'NONE_D'.
PERFORM select_none_download.
ELSEIF lv_ok_code = 'CLOSE'.
v_back_to_start = 'X'.
LEAVE TO SCREEN 0.
ELSE.
* check not more than 40 SCREEN items selected
LOOP AT i_fields INTO v_fields WHERE screen = 'X'.
ADD 1 TO lv_num_screen.
ENDLOOP.
IF lv_num_screen > 40.
* popup - only allowed to have < 40.
MESSAGE e034.
EXIT.
ELSEIF lv_num_screen = 0.
* popup - no screen items selected
MESSAGE e036.
EXIT.
ENDIF.
READ TABLE i_fields INTO v_fields WITH KEY download = 'X'.
IF sy-subrc <> 0.
* popup - no download items selected
MESSAGE e035.
EXIT.
ENDIF.
LEAVE TO SCREEN 0.
ENDIF.
ENDIF.
ENDMODULE. " process_buttons_2000 INPUT Runs the syntax checker on a number of programs in one go.*----------------------------------------------------------------------
* Program Name: Z_SYNTAX_CHECKER
* Author : Michael
* Description : Performs a syntax check on the given objects, listing
* those with errors.
*----------------------------------------------------------------------
REPORT Z_SYNTAX_CHECKER.
tables: tdevc, tadir, trdir.
select-options s_devc for tdevc-devclass.
select-options s_prog for sy-cprog.
data:
lv_trdir like trdir.
*--------------------------------------------------------*
start-of-selection.
perform syntax_check.
form syntax_check.
data:
check_include like sy-repid,
check_index like sy-tabix,
check_message(80) type c,
check_offs like sy-tabix,
check_subrc like sy-subrc.
data: fugr_name(8) type c value 'SAPLxxxx'.
data: begin of content occurs 0,
line(500) type c,
end of content.
data: wasanerror(1).
wasanerror = '0'.
select * from tadir where devclass in s_devc and
obj_name in s_prog and
( object eq 'PROG' or
object eq 'FUGR' )
order by primary key.
if tadir-object = 'FUGR'.
move tadir-obj_name to fugr_name+4(4).
move fugr_name to tadir-obj_name.
endif.
select single * from trdir into lv_trdir where name eq tadir-obj_name.
check sy-subrc eq 0.
check lv_trdir-subc ne 'I'. "Include??
refresh content.
read report lv_trdir-name into content.
if sy-subrc = 0.
call function 'EDITOR_SYNTAX_CHECK'
exporting
i_global_check = ' '
i_global_program = ' '
i_program = lv_trdir-name
importing
o_error_include = check_include
o_error_line = check_index
o_error_message = check_message
o_error_offset = check_offs
o_error_subrc = check_subrc
tables
i_source = content.
if check_subrc eq 0.
* no code
else.
write: lv_trdir-name, ',Error: ', check_message.
endif.
else.
write: 'Program: ', lv_trdir-name, 'Error: ', check_message.
endif.
endselect.
endform. A template program that runs a SmartForm and prints the output.REPORT z_smartform_template_print.
DATA:
v_control_params TYPE ssfctrlop,
v_output_options TYPE ssfcompop,
v_output_info TYPE ssfcrescl.
*---------------------------------------------------------------------*
* START-OF-SELECTION
*---------------------------------------------------------------------*
START-OF-SELECTION.
CLEAR:
v_output_info.
PERFORM setup_smartform_for_print USING 'LOPC'.
PERFORM run_smartform
USING 'MYSMARTFORM'
v_control_params
v_output_options
CHANGING
v_output_info.
*---------------------------------------------------------------------*
* FORM setup_smartform_for_print
*---------------------------------------------------------------------*
* [+] Sets the parameters for PDF conversions
*---------------------------------------------------------------------*
FORM setup_smartform_for_print
USING
p_printr TYPE rspopname.
CLEAR:
v_control_params,
v_output_options.
v_output_options-tddest = p_printr.
v_output_options-tdprinter = 'SAPWIN'.
v_output_options-tdnewid = 'X'.
v_output_options-tdimmed = 'X'.
v_output_options-tddelete = 'X'.
v_output_options-tdlifetime = 1.
v_output_options-tdfinal = 'X'.
v_control_params-device = 'PRINTER'.
ENDFORM. "setup_smartform_for_print
*---------------------------------------------------------------------*
* FORM run_smartform
*---------------------------------------------------------------------*
* [+] Runs the SmartForm of the given name
*---------------------------------------------------------------------*
FORM run_smartform
USING
p_form_name TYPE c
p_control_params TYPE ssfctrlop
p_output_options TYPE ssfcompop
CHANGING
p_output_info TYPE ssfcrescl.
DATA:
lv_function_name TYPE rs38l_fnam.
* Find the SmartForm function module name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form_name
IMPORTING
fm_name = lv_function_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 99.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Run the SmartForm function module
CALL FUNCTION p_form_name
EXPORTING
control_parameters = p_control_params
output_options = p_output_options
user_settings = ' '
IMPORTING
job_output_info = p_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 99.
ENDFORM. "run_smartform SmartForm PDF GeneratorREPORT z_smartform_template_pdf.
DATA:
v_control_params TYPE ssfctrlop,
v_output_options TYPE ssfcompop,
v_output_info TYPE ssfcrescl.
DATA:
i_pdf_data TYPE tline_t.
DATA:
v_spool_id TYPE rspoid,
v_num_bytes TYPE i,
v_filename TYPE string VALUE 'filename.pdf'.
*---------------------------------------------------------------------*
* START-OF-SELECTION
*---------------------------------------------------------------------*
START-OF-SELECTION.
CLEAR:
v_output_info,
i_pdf_data.
REFRESH:
i_pdf_data.
PERFORM setup_smartform_for_pdf.
PERFORM run_smartform
USING 'MYSMARTFORM'
v_control_params
v_output_options
CHANGING
v_output_info.
LOOP AT v_output_info-spoolids INTO v_spool_id.
* Convert the spool to a PDF document
PERFORM convert_otf_spool_to_pdf
USING
v_spool_id
CHANGING
v_num_bytes
i_pdf_data.
* Downloading the PDF document to the local PC
PERFORM download_pdf_to_file
USING
v_num_bytes
v_filename
i_pdf_data.
ENDLOOP.
*---------------------------------------------------------------------*
* FORM setup_smartform_for_pdf
*---------------------------------------------------------------------*
* [+] Sets the parameters for PDF conversions
*---------------------------------------------------------------------*
FORM setup_smartform_for_pdf.
CLEAR:
v_control_params,
v_output_options.
v_output_options-tddest = 'LOCP'.
v_output_options-tdprinter = 'SAPWIN'.
v_output_options-tdnewid = 'X'.
v_output_options-tdimmed = space.
v_output_options-tddelete = 'X'.
v_output_options-tdlifetime = 1.
v_output_options-tdfinal = 'X'.
v_control_params-no_dialog = 'X'.
v_control_params-device = 'PRINTER'.
ENDFORM. "setup_smartform_for_pdf
*---------------------------------------------------------------------*
* FORM run_smartform
*---------------------------------------------------------------------*
* [+] Runs the SmartForm of the given name
*---------------------------------------------------------------------*
FORM run_smartform
USING
p_form_name TYPE c
p_control_params TYPE ssfctrlop
p_output_options TYPE ssfcompop
CHANGING
p_output_info TYPE ssfcrescl.
DATA:
lv_function_name TYPE rs38l_fnam.
* Find the SmartForm function module name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form_name
IMPORTING
fm_name = lv_function_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 99.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Run the SmartForm function module
CALL FUNCTION p_form_name
EXPORTING
control_parameters = p_control_params
output_options = p_output_options
user_settings = ' '
IMPORTING
job_output_info = p_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 99.
ENDFORM. "run_smartform
*----------------------------------------------------------------------*
* FORM convert_otf_spool_to_pdf
*----------------------------------------------------------------------*
* [+] Converts a OTF spool document to a PDF data stream
*----------------------------------------------------------------------*
FORM convert_otf_spool_to_pdf
USING
p_spool_id TYPE rspoid " spool id number
CHANGING
p_num_bytes TYPE i " no. of bytes in output
p_pdf TYPE tline_t. " the output
* Write the spooled report to a PDF file
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = p_spool_id
no_dialog = ' '
IMPORTING
pdf_bytecount = p_num_bytes
TABLES
pdf = p_pdf
EXCEPTIONS
OTHERS = 99.
ENDFORM. "convert_otf_spool_to_pdf
*----------------------------------------------------------------------*
* FORM download_pdf_to_file
*----------------------------------------------------------------------*
* [+] Downloads PDF data (TLINE) to a local file
*----------------------------------------------------------------------*
FORM download_pdf_to_file
USING
p_num_bytes TYPE i
p_filename TYPE string
p_data TYPE tline_t.
DATA:
lv_append TYPE xfeld.
* Download the PDF data to a file on the users' computer
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = p_num_bytes
filename = p_filename
filetype = 'BIN'
append = lv_append
CHANGING
data_tab = p_data
EXCEPTIONS
OTHERS = 99.
ENDFORM. "download_pdf_to_file SmartForm Displaying/Previewing“A template program for running a SmartForm and previewing it. The previewing is done separate to the standard previewing, so “that you can have control over the pages separately. Includes the following functionality... REPORT z_smartform_template_display.
DATA:
v_control_params TYPE ssfctrlop,
v_output_options TYPE ssfcompop,
v_output_info TYPE ssfcrescl.
* OTF Data for previewing
DATA:
i_otf TYPE tsfotf,
v_otf LIKE LINE OF i_otf.
* A single page
DATA:
v_preview_page TYPE itcoo,
i_preview_page TYPE STANDARD TABLE OF itcoo.
DATA:
BEGIN OF i_gui_preview OCCURS 0.
INCLUDE STRUCTURE itcoo.
DATA:
END OF i_gui_preview.
* Bitmaps used in the preview
TYPES:
BEGIN OF t_bitmaps,
bm_index LIKE sy-tabix, " Index in Table OTF
bm_doc_id(42) TYPE c, " DOC-ID of the Bitmap
END OF t_bitmaps.
DATA:
v_bitmaps TYPE t_bitmaps,
i_bitmaps TYPE STANDARD TABLE OF t_bitmaps.
* details about the preview
TYPES:
BEGIN OF t_preview_info,
curr_pag LIKE ssfpp-tdpages, " Page Number
op_index LIKE sy-tabix, " Index in Table OTF
END OF t_preview_info.
DATA:
v_preview_info TYPE t_preview_info,
i_preview_info TYPE STANDARD TABLE OF t_preview_info.
*---------------------------------------------------------------------*
* START-OF-SELECTION
*---------------------------------------------------------------------*
START-OF-SELECTION.
CLEAR:
v_output_info.
PERFORM setup_smartform_for_display.
PERFORM run_smartform
USING 'MYSMARTFORM'
v_control_params
v_output_options
CHANGING
v_output_info.
* Retrieve the generated output
i_otf = v_output_info-otfdata.
* prepare the data for previewing.
PERFORM load_preview_bitmaps.
PERFORM get_preview_page_count.
* Loads page 1 of the preview
PERFORM show_preview_page
USING
1.
*---------------------------------------------------------------------*
* FORM setup_smartform_for_display
*---------------------------------------------------------------------*
* [+] Sets the parameters for PDF conversions
*---------------------------------------------------------------------*
FORM setup_smartform_for_display.
CLEAR:
v_control_params,
v_output_options.
v_output_options-tddest = 'LOCP'.
v_output_options-tdprinter = 'SAPWIN'.
v_output_options-tdnewid = 'X'.
v_output_options-tdimmed = space.
v_output_options-tddelete = 'X'.
v_output_options-tdlifetime = 1.
v_output_options-tdfinal = 'X'.
v_control_params-no_dialog = 'X'.
v_control_params-device = 'PRINTER'.
v_control_params-preview = 'X'.
v_control_params-getotf = 'X'.
ENDFORM. "setup_smartform_for_display
*---------------------------------------------------------------------*
* FORM run_smartform
*---------------------------------------------------------------------*
* [+] Runs the SmartForm of the given name
*---------------------------------------------------------------------*
FORM run_smartform
USING
p_form_name TYPE c
p_control_params TYPE ssfctrlop
p_output_options TYPE ssfcompop
CHANGING
p_output_info TYPE ssfcrescl.
DATA:
lv_function_name TYPE rs38l_fnam.
* Find the SmartForm function module name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form_name
IMPORTING
fm_name = lv_function_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 99.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Run the SmartForm function module
CALL FUNCTION p_form_name
EXPORTING
control_parameters = p_control_params
output_options = p_output_options
user_settings = ' '
IMPORTING
job_output_info = p_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 99.
ENDFORM. "run_smartform
*----------------------------------------------------------------------
* FORM load_preview_bitmaps
*----------------------------------------------------------------------
* [+] Prepares the bitmap images used in the print preview
*----------------------------------------------------------------------
FORM load_preview_bitmaps.
CLEAR:
v_bitmaps,
i_bitmaps.
LOOP AT i_otf
INTO v_otf
WHERE tdprintcom = 'BM'.
IF v_otf-tdprintpar+11(1) = 'D'.
v_bitmaps-bm_index = sy-tabix.
v_bitmaps-bm_doc_id = v_otf-tdprintpar+16(42).
APPEND v_bitmaps TO i_bitmaps.
ENDIF.
ENDLOOP.
ENDFORM. "load_preview_bitmaps
*----------------------------------------------------------------------
* FORM get_preview_page_count
*----------------------------------------------------------------------
* [+] Gets the number of pages in this preview.
* [+] Sets up the i_preview_info
*----------------------------------------------------------------------
FORM get_preview_page_count.
* Internal variables
DATA:
lv_pages LIKE ssfpp-tdpages.
* Clear variables
CLEAR:
lv_pages,
v_preview_info,
i_preview_info.
REFRESH:
i_preview_info.
LOOP AT i_otf
INTO v_otf
WHERE tdprintcom = 'OP'. "Open Page
v_preview_info-op_index = sy-tabix.
ADD 1 TO lv_pages.
v_preview_info-curr_pag = lv_pages.
APPEND v_preview_info TO i_preview_info.
ENDLOOP.
CLEAR:
v_preview_info.
ENDFORM. "get_preview_page_count
*----------------------------------------------------------------------
* FORM show_preview_page
*----------------------------------------------------------------------
* [+] Loads the given page number in the preview
*----------------------------------------------------------------------
FORM show_preview_page
USING
p_page_number TYPE txpagenr.
* Internal variables
DATA:
lv_current_index LIKE sy-tabix.
* Clear variables
CLEAR:
v_preview_page,
i_preview_page.
REFRESH
i_preview_page.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 25
text = 'Please wait...'.
* already on the correct page
CHECK v_preview_info-curr_pag <> p_page_number.
READ TABLE i_preview_info
INTO v_preview_info
INDEX p_page_number.
CHECK sy-subrc = 0.
* preview header data
v_preview_page-tdprintcom = '//'.
APPEND v_preview_page TO i_preview_page.
* preview page data
lv_current_index = v_preview_info-op_index.
DO.
READ TABLE i_otf
INTO v_otf
INDEX lv_current_index.
IF sy-subrc <> 0.
EXIT.
ENDIF.
v_preview_page = v_otf.
CASE v_preview_page-tdprintcom.
WHEN 'RD'. "Raw Data
APPEND v_preview_page TO i_preview_page.
WHEN 'EP'. "Close Page
APPEND v_preview_page TO i_preview_page.
EXIT.
WHEN OTHERS.
APPEND v_preview_page TO i_preview_page.
ENDCASE.
ADD 1 TO lv_current_index.
ENDDO.
ENDFORM. "show_preview_page
*----------------------------------------------------------------------
* FORM show_next_page
*----------------------------------------------------------------------
* [+] Shows the next page
*----------------------------------------------------------------------
FORM show_next_page.
DATA: lv_page_number TYPE txpagenr,
lv_last_page TYPE i.
lv_page_number = v_preview_info-curr_pag.
ADD 1 TO lv_page_number.
DESCRIBE TABLE i_preview_info LINES lv_last_page.
IF lv_page_number > lv_last_page.
lv_page_number = lv_last_page.
ENDIF.
IF lv_page_number <> v_preview_info-curr_pag.
PERFORM show_preview_page
USING
lv_page_number.
ENDIF.
ENDFORM. "show_next_page
*----------------------------------------------------------------------
* FORM show_previous_page
*----------------------------------------------------------------------
* [+] Shows the previous page
*----------------------------------------------------------------------
FORM show_previous_page.
DATA: lv_page_number TYPE txpagenr.
lv_page_number = v_preview_info-curr_pag.
SUBTRACT 1 FROM lv_page_number.
IF lv_page_number <= 0.
lv_page_number = 1.
ENDIF.
IF lv_page_number <> v_preview_info-curr_pag.
PERFORM show_preview_page
USING
lv_page_number.
ENDIF.
ENDFORM. "show_previous_page
*----------------------------------------------------------------------
* FORM show_first_page
*----------------------------------------------------------------------
* [+] Shows the first page
*----------------------------------------------------------------------
FORM show_first_page.
DATA: lv_page_number TYPE txpagenr.
lv_page_number = 1.
IF lv_page_number <> v_preview_info-curr_pag.
PERFORM show_preview_page
USING
lv_page_number.
ENDIF.
ENDFORM. "show_first_page
*----------------------------------------------------------------------
* FORM show_last_page
*----------------------------------------------------------------------
* [+] Shows the first page
*----------------------------------------------------------------------
FORM show_last_page.
DATA: lv_page_number TYPE txpagenr.
DESCRIBE TABLE i_preview_info LINES lv_page_number.
IF lv_page_number <> v_preview_info-curr_pag.
PERFORM show_preview_page
USING
lv_page_number.
ENDIF.
ENDFORM. "show_last_page
*----------------------------------------------------------------------
* MODULE display_preview
*----------------------------------------------------------------------
* [+] Prepares the print preview for being displayed
*
* THIS SHOULD BE PUT IN THE "PROCESS BEFORE OUTPUT" OF THE SCREEN
*
*----------------------------------------------------------------------
MODULE display_preview OUTPUT.
CALL FUNCTION 'PREPARE_OTF_FOR_GUI_PREVIEWER'
EXPORTING
otf_raw = i_preview_page[]
defined_bitmaps = i_bitmaps[]
IMPORTING
otf_preview = i_gui_preview[]
TABLES
otf = i_otf[]
EXCEPTIONS
OTHERS = 0.
* show the preview
CALL 'C_TRADR' ID 'OUTTAB' FIELD i_gui_preview[]
ID 'APPL' FIELD 'SCRIPT'.
ENDMODULE. "display_preview OUTPUT Sets the range for a select-option*----------------------------------------------------------------------*
* FORM set_range
*----------------------------------------------------------------------*
* [+] Sets the range for a select-option
*----------------------------------------------------------------------*
FORM set_range
USING
p_high TYPE RSDSSELOP_
p_low TYPE RSDSSELOP_
CHANGING
p_selopt TYPE RSELOPTION.
DATA:
lv_single_opt LIKE LINE OF p_selopt.
CLEAR:
lv_single_opt,
p_selopt.
REFRESH:
p_selopt.
lv_single_opt-high = p_high.
lv_single_opt-low = p_low.
APPEND lv_single_opt TO p_selopt.
ENDFORM. A Form that sends a email with a message and attachments.*----------------------------------------------------------------------*
* Data and types for send_email
*----------------------------------------------------------------------*
* raw data for attachment
TYPES:
BEGIN OF t_data,
lifnr TYPE elifn,
name1 TYPE name1_gp,
END OF t_data.
DATA:
i_data TYPE STANDARD TABLE OF t_data,
v_data TYPE t_data.
* attachment details and formatted data
TYPES:
BEGIN OF t_attach_file,
file_name TYPE so_obj_des,
file_ext TYPE so_obj_tp,
attach TYPE soli_tab,
END OF t_attach_file,
ti_attach_file TYPE STANDARD TABLE OF t_attach_file.
* receivers table
TYPES:
BEGIN OF t_email_address,
address TYPE ad_smtpadr,
END OF t_email_address,
ti_email_address TYPE STANDARD TABLE OF t_email_address.
*----------------------------------------------------------------------*
* FORM send_email
*----------------------------------------------------------------------*
* [+] Sends an email with a message and attachment
*----------------------------------------------------------------------*
FORM send_email
USING
p_email TYPE ad_smtpadr.
CONSTANTS:
c_subject TYPE so_obj_des VALUE 'Email Subject',
c_tab(1) TYPE x VALUE '09',
c_linebreak(2) TYPE x VALUE '0D0A',
c_filename(50) TYPE c VALUE 'file_attachment_01',
c_txt(3) TYPE c VALUE 'txt'.
DATA:
li_message_body TYPE STANDARD TABLE OF soli,
lv_message_body LIKE LINE OF li_message_body,
li_attachment_data TYPE STANDARD TABLE OF soli,
lv_attachment_data LIKE LINE OF li_attachment_data,
lv_email_data TYPE t_attach_file,
li_email_data TYPE ti_attach_file,
li_email_address TYPE ti_email_address.
* Build the email body message
CLEAR: lv_message_body.
MOVE 'This is line 1'
TO lv_message_body.
APPEND lv_message_body TO li_message_body.
CLEAR: lv_message_body.
CONCATENATE
'This Is'
'Line 2'
INTO
lv_message_body SEPARATED BY space.
APPEND lv_message_body TO li_message_body.
CLEAR: lv_message_body.
MOVE 'This is line 3'
TO lv_message_body.
APPEND lv_message_body TO li_message_body.
* setting up attachment name
MOVE:
c_filename TO lv_email_data-file_name,
c_txt TO lv_email_data-file_ext.
* Build the attachment (text file)
* Column headings as first row
CLEAR: lv_attachment_data.
CONCATENATE
'Vendor'
'Name'
INTO
lv_attachment_data SEPARATED BY c_tab.
APPEND lv_attachment_data TO li_attachment_data.
* Extracting table data into remaining rows
LOOP AT i_data INTO v_data.
CLEAR: lv_attachment_data.
CONCATENATE
v_data-lifnr
v_data-name1
INTO
lv_attachment_data SEPARATED BY c_tab.
* add the line break
CONCATENATE
c_linebreak
lv_attachment_data
INTO
lv_attachment_data.
APPEND lv_attachment_data TO li_attachment_data.
ENDLOOP.
MOVE li_attachment_data TO lv_email_data-attach.
APPEND lv_email_data TO li_email_data.
CLEAR: lv_email_data.
* build email address table
APPEND p_email TO li_email_address.
* Send the email
PERFORM send_mail_api
USING
li_message_body
c_subject
li_email_address
li_email_data.
ENDFORM.
*----------------------------------------------------------------------*
* FORM send_mail_api
*----------------------------------------------------------------------*
* [+] Generic email sending
*----------------------------------------------------------------------*
FORM send_mail_api
USING
p_message_body TYPE soli_tab
p_message_subject TYPE sood1-objdes
p_recipient_email TYPE ti_email_address
p_attachment TYPE ti_attach_file.
*** CONSTANTS ***
CONSTANTS:
c_rt_internet TYPE soos1-recesc VALUE 'U'. "internet mail
*** DATA ***
DATA:
lv_tab_lines TYPE sy-tabix,
lv_obj_descr TYPE sodocchgi1-obj_descr,
lv_head_start TYPE sytabix,
lv_body_start TYPE sytabix.
*** STRUCTURES ***
DATA:
lv_objpack TYPE sopcklsti1,
lv_objhead TYPE solisti1,
lv_objbin TYPE solisti1,
lv_objtxt TYPE solisti1,
lv_reclist TYPE somlreci1,
lv_recipients TYPE somlreci1,
lv_doc_chng TYPE sodocchgi1,
lv_attachment TYPE t_attach_file,
lv_recipient_email TYPE t_email_address.
*** INTERNAL TABLES ***
DATA:
li_objpack TYPE TABLE OF sopcklsti1,
li_objhead TYPE TABLE OF solisti1,
li_objbin TYPE TABLE OF solisti1,
li_objtxt TYPE TABLE OF solisti1,
li_objhex TYPE TABLE OF solix,
li_reclist TYPE TABLE OF somlreci1.
*** Build the message body
MOVE p_message_body TO li_objtxt.
DESCRIBE TABLE li_objtxt LINES lv_tab_lines.
READ TABLE li_objtxt INTO lv_objtxt INDEX lv_tab_lines.
lv_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255
+ STRLEN( lv_objtxt ).
MOVE p_message_subject TO lv_doc_chng-obj_descr.
CONDENSE lv_doc_chng-obj_descr.
* creation of the message
CLEAR lv_objpack-transf_bin.
lv_objpack-head_start = 1.
lv_objpack-head_num = 0.
lv_objpack-body_start = 1.
lv_objpack-doc_type = 'RAW'.
DESCRIBE TABLE li_objtxt LINES lv_objpack-body_num.
APPEND lv_objpack TO li_objpack.
CLEAR lv_objpack.
*** Build the attachments
LOOP AT p_attachment INTO lv_attachment.
DESCRIBE TABLE lv_attachment-attach LINES lv_tab_lines.
DESCRIBE TABLE li_objhex LINES lv_body_start.
DESCRIBE TABLE li_objhead LINES lv_head_start.
ADD 1 TO lv_head_start.
ADD 1 TO lv_body_start.
lv_objpack-transf_bin = 'X'.
lv_objpack-head_start = lv_head_start.
lv_objpack-head_num = 1.
lv_objpack-body_start = lv_body_start.
lv_objpack-body_num = lv_tab_lines.
lv_objpack-doc_type = lv_attachment-file_ext.
lv_objpack-obj_name = lv_attachment-file_ext.
CONCATENATE
lv_attachment-file_name
'.'
lv_attachment-file_ext
INTO
lv_obj_descr.
lv_objpack-obj_descr = lv_obj_descr.
lv_objpack-doc_size = lv_tab_lines * 255.
APPEND lv_objpack TO li_objpack.
CLEAR lv_objpack.
* creation of the document attachment
APPEND LINES OF lv_attachment-attach TO li_objhex.
* build file information into header
MOVE lv_obj_descr TO lv_objhead.
APPEND lv_objhead TO li_objhead.
CLEAR: lv_objhead.
CLEAR: lv_tab_lines.
ENDLOOP.
*** Build recipients
IF p_recipient_email IS INITIAL.
EXIT.
ENDIF.
* build recipients table
LOOP AT p_recipient_email INTO lv_recipient_email.
CLEAR lv_reclist.
lv_reclist-rec_type = c_rt_internet.
lv_reclist-receiver = lv_recipient_email-address.
APPEND lv_reclist TO li_reclist .
ENDLOOP.
*** Send the email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lv_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = li_objpack
object_header = li_objhead
contents_bin = li_objbin
contents_txt = li_objtxt
contents_hex = li_objhex
receivers = li_reclist
EXCEPTIONS
OTHERS = 99.
ENDFORM. Sends a regular email (ie. no attachments, only a message)*----------------------------------------------------------------------*
* FORM send_basic_email
*----------------------------------------------------------------------*
* [+] Sends a regular email (ie. no attachments, only a message)
*----------------------------------------------------------------------*
FORM send_basic_email
USING
p_email TYPE ad_smtpadr
p_message TYPE STANDARD TABLE OF char255.
DATA:
lv_pack_list TYPE sopcklsti1,
li_pack_list TYPE STANDARD TABLE OF sopcklsti1,
lv_receivers TYPE somlreci1,
li_receivers TYPE STANDARD TABLE OF somlreci1,
lv_email_details TYPE sodocchgi1.
CLEAR:
lv_pack_list,
li_pack_list,
lv_receivers,
li_receivers,
lv_email_details.
REFRESH:
li_pack_list,
li_receivers.
* Setup the email details
lv_email_details-obj_name = 'My Email'.
lv_email_details-obj_descr = 'My really cool email'.
lv_email_details-obj_langu = 'E'.
* Describe the email contents
DESCRIBE TABLE p_message LINES lv_pack_list-body_num.
lv_pack_list-head_start = 1.
lv_pack_list-head_num = 0.
lv_pack_list-body_start = 1.
lv_pack_list-doc_type = 'RAW'.
APPEND lv_pack_list TO li_pack_list.
* Create receiver list
lv_receivers-receiver = p_email.
lv_receivers-rec_type = 'U'.
lv_receivers-com_type = 'INT'.
APPEND lv_receivers TO li_receivers.
* Send the email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lv_email_details
put_in_outbox = 'X'
TABLES
packing_list = li_pack_list
contents_txt = p_message
receivers = li_receivers
EXCEPTIONS
OTHERS = 99.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDFORM. CONVERT_SECONDS_TO_TIMESTAMP*---------------------------------------------------------------------*
* FORM CONVERT_SECONDS_TO_TIMESTAMP
*---------------------------------------------------------------------*
* [+] Converts a number of seconds into a timestamp HH:MM:SS
*---------------------------------------------------------------------*
FORM convert_seconds_to_timestamp
USING
value(p_number) TYPE i
CHANGING
p_time TYPE c.
DATA:
lv_hours(2) TYPE n,
lv_minutes(2) TYPE n,
lv_seconds(2) TYPE n.
lv_hours = p_number DIV 3600.
lv_minutes = ( p_number - ( lv_hours * 3600 ) ) DIV 60.
lv_seconds = p_number - ( lv_hours * 3600 ) - ( lv_minutes * 60 ).
CONCATENATE lv_hours ':' lv_minutes ':' lv_seconds INTO p_time.
ENDFORM. "convert_seconds_to_timestamp Right-aligns the text in the character field*----------------------------------------------------------------------*
* FORM RIGHT_ALIGN
*----------------------------------------------------------------------*
* [+] Right-aligns the text in the character field
*----------------------------------------------------------------------*
FORM right_align
USING
p_padding_char TYPE c
CHANGING
p_text TYPE c.
DATA:
lv_text_length TYPE i,
lv_field_length TYPE i,
lv_remaining TYPE i.
lv_text_length = strlen( p_text ).
DESCRIBE FIELD p_text LENGTH lv_field_length.
lv_remaining = lv_field_length - lv_text_length.
if lv_remaining = 0.
exit.
endif.
WRITE p_text TO p_text+lv_remaining.
SUBTRACT 1 FROM lv_remaining.
WHILE lv_remaining >= 0.
WRITE p_padding_char TO p_text+lv_remaining(1).
SUBTRACT 1 FROM lv_remaining.
ENDWHILE.
ENDFORM. Removes the zeros from the left of the field*----------------------------------------------------------------------*
* FORM REMOVE_ZEROS
*----------------------------------------------------------------------*
* [+] Removes the zeros from the left of the field
*----------------------------------------------------------------------*
FORM remove_zeros
CHANGING
p_text TYPE c.
DATA:
lv_field_length TYPE i,
lv_copy_length TYPE i.
DESCRIBE FIELD p_text LENGTH lv_field_length.
lv_copy_length = lv_field_length - 1.
WHILE p_text(1) = '0'.
WRITE p_text+1(lv_copy_length) TO p_text+0(lv_field_length).
ENDWHILE.
ENDFORM. Removes the editor locks for the given objects*---------------------------------------------------------------------- * Program Name: Z_REMOVE_EDITOR_LOCK * Author : Michael * Description : Removes the editor locks for the given objects
*----------------------------------------------------------------------
REPORT Z_REMOVE_EDITOR_LOCK.
TABLES: trdir.
SELECT-OPTIONS: PROG FOR trdir-NAME.
UPDATE PROGDIR SET EDTX = SPACE
WHERE NAME IN PROG.
WRITE: 'Reset ok when number 0 appears ->', SYST-SUBRC. |
|
|