SAP ABAP VARIOS
From SapWiki
Contents
UUID ver nota 935047 - Creating and using GUIDs (UUIDs)
FORM generar_iddocumento_2 CHANGING p_resultado. DATA lcl_request_id TYPE guid_32. TRY. lcl_request_id = cl_system_uuid=>create_uuid_c32_static( ). CATCH cx_uuid_error. ASSERT 1 = 0. ENDTRY. MOVE lcl_request_id TO p_resultado. ENDFORM.
Grabar XSTRING en equipo como Binario(XML,PDF,etc.)
CONCATENATE ls_dir_d '\' i_vbeln '.xml' INTO ls_fullpath.
CALL METHOD cl_faa_tenv_services=>gui_download_xstring EXPORTING id_fullpath = ls_fullpath id_xstring = i_xml.
IF sy-subrc <> 0.
ENDIF.
Obtener Texto según Valor de dominio
FORM get_domvalue USING p_domname p_value CHANGING p_text. DATA: l_domvalue TYPE dd07v-domvalue_l, l_ddtext TYPE dd07v-ddtext. l_domvalue = p_value. CALL FUNCTION 'DOMAIN_VALUE_GET' EXPORTING i_domname = p_domname i_domvalue = l_domvalue IMPORTING e_ddtext = l_ddtext EXCEPTIONS not_exist = 1 OTHERS = 2. IF sy-subrc = 0. MOVE l_ddtext TO p_text. ELSE. CLEAR p_text. ENDIF. ENDFORM. "get_domvalue
Bajar tabla en formato CSV (función hr_cl_if_prvd_generate_file)
FUNCTION hr_cl_if_prvd_generate_file. *"---------------------------------------------------------------------- *"*"Local Interface: *" TABLES *" IT_DATA TYPE STANDARD TABLE *"---------------------------------------------------------------------- FIELD-SYMBOLS: <f_source>. TYPES data_c(4096) TYPE c. TYPES t_data_c TYPE data_c OCCURS 0. CONSTANTS: c_field_separator TYPE c VALUE ';', c_darl_number(12) TYPE c VALUE '1234567890 '. DATA: lt_data_csv TYPE t_data_c, l_struc_index TYPE syindex, l_len_string TYPE i, l_max_field TYPE data_c, l_struc_raw_data TYPE data_c, l_start_string TYPE i, l_len_field_sep TYPE i, l_type, l_date_extern(30) TYPE c, l_help_id LIKE tline-tdline, l_tabix TYPE sytabix. l_len_field_sep = STRLEN( c_field_separator ). LOOP AT it_data. CLEAR: l_struc_index, l_len_string, l_struc_raw_data, l_start_string. DO. ADD 1 TO l_struc_index. CLEAR l_len_string. ASSIGN COMPONENT l_struc_index OF STRUCTURE it_data TO <f_source>. IF sy-subrc <> '0'. EXIT. ELSE. * * special processing when field is type data DESCRIBE FIELD <f_source> TYPE l_type. CASE l_type. WHEN 'P'. WRITE <f_source> TO l_date_extern. CATCH SYSTEM-EXCEPTIONS conversion_errors = 4. IF sy-subrc <> '0'. MESSAGE e899(ux) WITH l_type <f_source> l_help_id l_tabix RAISING conversion_failed. ENDIF. ENDCATCH. ASSIGN l_date_extern TO <f_source>. WHEN 'X'. ASSIGN COMPONENT l_struc_index OF STRUCTURE it_data TO <f_source> TYPE 'C'. WRITE <f_source> TO l_date_extern. ASSIGN l_date_extern TO <f_source>. WHEN 'T'. CLEAR l_date_extern. l_date_extern(2) = <f_source>(2). l_date_extern+2(1) = ':'. l_date_extern+3(2) = <f_source>+2(2). l_date_extern+5(1) = ':'. l_date_extern+6(2) = <f_source>+4(2). ASSIGN l_date_extern TO <f_source>. WHEN 'D'. CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL' EXPORTING date_internal = <f_source> IMPORTING date_external = l_date_extern EXCEPTIONS 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 RAISING conversion_failed. ELSE. ASSIGN l_date_extern TO <f_source>. ENDIF. WHEN 'F'. CALL FUNCTION 'FLTP_CHAR_CONVERSION' EXPORTING input = <f_source> IMPORTING flstr = l_date_extern EXCEPTIONS 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 RAISING conversion_failed. ELSE. ASSIGN l_date_extern TO <f_source>. ENDIF. WHEN OTHERS. ENDCASE. * remember der seperation character! IF l_struc_index <> 1. l_max_field+l_len_string(l_len_field_sep) = c_field_separator. l_len_string = l_len_field_sep. ENDIF. IF <f_source> CO c_darl_number. CONDENSE <f_source> NO-GAPS. ELSE. CONDENSE <f_source>. ENDIF. l_max_field+l_len_string = <f_source>. l_len_string = STRLEN( l_max_field ). CHECK l_len_string <> '0'. l_struc_raw_data+l_start_string(l_len_string) = l_max_field. l_start_string = l_start_string + l_len_string. ENDIF. ENDDO. IF NOT l_struc_raw_data IS INITIAL. APPEND l_struc_raw_data TO lt_data_csv. ENDIF. ENDLOOP. CALL FUNCTION 'HR_99S_DOWNLOAD' EXPORTING p_initial_directory = 'C:\' p_filename = 'PREVIRED.txt' p_filetype = 'ASC' p_write_lf = 'X' p_trunc_blanks_eol = 'X' p_trunc_blanks = ' ' TABLES data_tab = lt_data_csv EXCEPTIONS file_save_dialog = 1 file_write_error = 2 no_batch = 3 gui_refuse_filetransfer = 4 invalid_type = 5 unknown_error = 6 wrong_tab_format = 7 OTHERS = 8. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFUNCTION.
Crear Datos SFLIGHT
Sap provee de un modelo de datos, basado en aerolineas, para sus programas demo o training, para generar datos usar programa SAPBC_DATA_GENERATOR