hxxxrz

Untitled

Aug 4th, 2021 (edited)
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 10.92 KB | None | 0 0
  1. class YCLITC_PRINTED_FORM_TEMPLATE definition
  2.   public
  3.   create public .
  4.  
  5. *"* public components of class YCLITC_PRINTED_FORM_TEMPLATE
  6. *"* do not include other source files here!!!
  7. public section.
  8.  
  9.   methods CONSTRUCTOR
  10.     importing
  11.       value(I_FILE_SOURCE) type STRING optional
  12.       value(I_SOURCE_TYPE) type YEITC_FILE_SOURCE_TYPE default 'WWW'
  13.       !IT_VALUES type YTTITC_PRINTED_FORM_VALUES
  14.       !IT_FILES type YTTITC_PRINTED_FORM_FILES optional .
  15.   methods RUN
  16.   final
  17.     exceptions
  18.       FILE_NOT_FOUND
  19.       PRINT_CANCEL .
  20.   methods SET_USER_CLASS
  21.   final
  22.     importing
  23.       !IO_USER_CLASS type ref to OBJECT .
  24.   methods SET_PARAMETERS
  25.     importing
  26.       value(I_FORM_NAME) type YSITC_PRINTED_FORM_PARAMS-FORM_NAME optional
  27.       value(I_FILE_NAME) type YSITC_PRINTED_FORM_PARAMS-FILE_NAME optional
  28.       value(I_FILE_LOCATION) type C optional
  29.       value(I_PRINTDIALOG) type C optional
  30.       value(I_PROTECT) type C optional
  31.       value(I_OPTIMIZE) type YSITC_PRINTED_FORM_PARAMS-OPTIMIZE optional
  32.       value(I_DEBUG_MODE) type C optional
  33.       value(I_DECIMAL_SEPARATOR) type C optional
  34.       value(I_CLOSE_FORM) type C optional
  35.       value(I_DELETE_FILE) type C optional
  36.       value(I_WITHOUT_OLE) type C optional
  37.       value(I_USE_JAR) type C optional
  38.       value(I_USE_UNICODE) type C optional
  39.       value(I_FORM_TYPE) type CHAR30 optional .
  40.   methods GET_DEFAULT_PARAMETERS
  41.     returning
  42.       value(RS_PARAMETERS) type YSITC_PRINTED_FORM_PARAMS .
  43. protected section.
  44. *"* protected components of class YCLITC_PRINTED_FORM_TEMPLATE
  45. *"* do not include other source files here!!!
  46.  
  47.   types T_EXT type CHAR255 .
  48.   types T_FILETYPE type CHAR50 .
  49.  
  50.   data G_FILE_SOURCE type STRING .
  51.   data G_SOURCE_TYPE type YEITC_FILE_SOURCE_TYPE .
  52.   data GO_UTILS type ref to YCLITC_UTILITIES .
  53.   data GO_UTIL_FILES type ref to YCLITC_UTIL_FILES .
  54.  
  55.   methods READ_TEMPLATE
  56.     importing
  57.       !IS_PARAMETERS type YSITC_PRINTED_FORM_PARAMS
  58.     exporting
  59.       !ES_DATA type YSITC_PRINTED_FORM_DATA
  60.     exceptions
  61.       FILE_NOT_FOUND .
  62. private section.
  63. *"* private components of class YCLITC_PRINTED_FORM_TEMPLATE
  64. *"* do not include other source files here!!!
  65.  
  66.   data GS_PARAMETERS type YSITC_PRINTED_FORM_PARAMS .
  67.   data GT_VALUES type YTTITC_PRINTED_FORM_VALUES .
  68.   data GT_FILES type YTTITC_PRINTED_FORM_FILES .
  69.   data GO_USER_CLASS type ref to OBJECT .
  70. ENDCLASS.
  71.  
  72.  
  73.  
  74. CLASS YCLITC_PRINTED_FORM_TEMPLATE IMPLEMENTATION.
  75.  
  76.  
  77. * <SIGNATURE>---------------------------------------------------------------------------------------+
  78. * | Instance Public Method YCLITC_PRINTED_FORM_TEMPLATE->CONSTRUCTOR
  79. * +-------------------------------------------------------------------------------------------------+
  80. * | [--->] I_FILE_SOURCE                  TYPE        STRING(optional)
  81. * | [--->] I_SOURCE_TYPE                  TYPE        YEITC_FILE_SOURCE_TYPE (default ='WWW')
  82. * | [--->] IT_VALUES                      TYPE        YTTITC_PRINTED_FORM_VALUES
  83. * | [--->] IT_FILES                       TYPE        YTTITC_PRINTED_FORM_FILES(optional)
  84. * +--------------------------------------------------------------------------------------</SIGNATURE>
  85.   method CONSTRUCTOR.
  86.   Data:
  87.     l_FileName type string,
  88.     l_Name     type string,
  89.     l_Ext      type string.
  90.  
  91. *  Call method SUPER->Constructor.
  92.  
  93.   Create object GO_UTILS.
  94.   Create object go_Util_Files.
  95.  
  96.   GS_PARAMETERS = GET_DEFAULT_PARAMETERS( ).
  97. *  GS_PARAMETERS = IS_PARAMETERS.
  98.  
  99.   G_FILE_SOURCE = I_FILE_SOURCE.
  100.   G_SOURCE_TYPE = I_SOURCE_TYPE.
  101.  
  102.   GT_VALUES = IT_VALUES.
  103.   GT_FILES = IT_FILES.
  104.  
  105.   If not I_FILE_SOURCE is initial.
  106.     Call method GO_UTILS->SPLIT_FILE_AND_PATH
  107.       EXPORTING
  108.         I_FULL_NAME = I_FILE_SOURCE
  109.       IMPORTING
  110.         E_FILE_NAME = l_FileName.
  111.  
  112.     Call method GO_UTILS->SPLIT_FILE_AND_EXT
  113.       EXPORTING
  114.         I_FILE_NAME = l_FileName
  115.       IMPORTING
  116.         E_NAME      = l_Name
  117.         E_EXT       = l_Ext.
  118.  
  119.     Translate l_Name to upper case.
  120.  
  121.     Call method Set_Parameters
  122.       EXPORTING
  123.         I_FORM_NAME = l_Name.
  124.   EndIf.
  125.   endmethod.
  126.  
  127.  
  128. * <SIGNATURE>---------------------------------------------------------------------------------------+
  129. * | Instance Public Method YCLITC_PRINTED_FORM_TEMPLATE->GET_DEFAULT_PARAMETERS
  130. * +-------------------------------------------------------------------------------------------------+
  131. * | [<-()] RS_PARAMETERS                  TYPE        YSITC_PRINTED_FORM_PARAMS
  132. * +--------------------------------------------------------------------------------------</SIGNATURE>
  133.   method GET_DEFAULT_PARAMETERS.
  134.   RS_PARAMETERS-FILE_NAME   = ''.
  135.   RS_PARAMETERS-FILE_LOCATION   = ''.
  136.   RS_PARAMETERS-PRINTDIALOG =   ''.
  137.   RS_PARAMETERS-PROTECT = 'X'.
  138.   RS_PARAMETERS-OPTIMIZE = 100.
  139.   RS_PARAMETERS-DEBUG_MODE = ''.
  140.   RS_PARAMETERS-DECIMAL_SEPARATOR   =   '.'.
  141.   RS_PARAMETERS-CLOSE_FORM = ''.
  142.   RS_PARAMETERS-DELETE_FILE = 'X'.
  143.   RS_PARAMETERS-WITHOUT_OLE = ''.
  144.   RS_PARAMETERS-USE_JAR = ''.
  145.   RS_PARAMETERS-USE_UNICODE = ''.
  146.   endmethod.
  147.  
  148.  
  149. * <SIGNATURE>---------------------------------------------------------------------------------------+
  150. * | Instance Protected Method YCLITC_PRINTED_FORM_TEMPLATE->READ_TEMPLATE
  151. * +-------------------------------------------------------------------------------------------------+
  152. * | [--->] IS_PARAMETERS                  TYPE        YSITC_PRINTED_FORM_PARAMS
  153. * | [<---] ES_DATA                        TYPE        YSITC_PRINTED_FORM_DATA
  154. * | [EXC!] FILE_NOT_FOUND
  155. * +--------------------------------------------------------------------------------------</SIGNATURE>
  156.   method READ_TEMPLATE.
  157.   Data:
  158.     l_FileName  type string,
  159.     l_Ext       type string,
  160.     ls_FileInfo type YSITC_CATALOG_LIST.
  161.  
  162.   If not G_FILE_SOURCE is initial and
  163.      not G_SOURCE_TYPE is initial.
  164.     Call method go_Util_Files->File_Load
  165.       EXPORTING
  166.         I_FILE_NAME   = G_FILE_SOURCE
  167.         I_SOURCE_TYPE = G_SOURCE_TYPE
  168.       IMPORTING
  169.         E_FILE_DATA   = ES_DATA-FILE_TEMPLATE
  170.         ES_FILE_INFO   = ls_FileInfo
  171.       EXCEPTIONS
  172.         others        = 99.
  173.  
  174. *    Call method GO_UTILS->Split_File_and_Path
  175. *      EXPORTING
  176. *        I_FULL_NAME = G_FILE_SOURCE
  177. *      IMPORTING
  178. *        E_FILE_NAME = l_FileName.
  179. *    Call method GO_UTILS->Split_File_and_Ext
  180. *      EXPORTING
  181. *        I_FILE_NAME = l_FileName
  182. *      IMPORTING
  183. *        E_EXT       = l_Ext.
  184. *    Translate l_Ext to upper case.
  185.     l_Ext = ls_FileInfo-Extension.
  186.     Concatenate '.' l_Ext into ES_DATA-FILE_TEMPLATE_EXT.
  187.   EndIf.
  188.  
  189.   endmethod.
  190.  
  191.  
  192. * <SIGNATURE>---------------------------------------------------------------------------------------+
  193. * | Instance Public Method YCLITC_PRINTED_FORM_TEMPLATE->RUN
  194. * +-------------------------------------------------------------------------------------------------+
  195. * | [EXC!] FILE_NOT_FOUND
  196. * | [EXC!] PRINT_CANCEL
  197. * +--------------------------------------------------------------------------------------</SIGNATURE>
  198.   method RUN.
  199.   Data:
  200.     ls_Data type YSITC_PRINTED_FORM_DATA.
  201.  
  202.   Call method READ_TEMPLATE
  203.     EXPORTING
  204.       IS_PARAMETERS = GS_PARAMETERS
  205.     IMPORTING
  206.       ES_DATA       = ls_Data
  207.     exceptions
  208.       FILE_NOT_FOUND = 1.
  209.   Case sy-subrc.
  210.     when 0.
  211.  
  212.     when 1.
  213.       Message E800(YITC_PRINTED_FORM) raising FILE_NOT_FOUND.
  214.     when others.
  215.  
  216.   EndCase.
  217.  
  218.   Call method YCLITC_PRINTED_FORM=>MAIN
  219.     EXPORTING
  220.       IS_PARAMETERS = GS_PARAMETERS
  221.       IT_FILES      = GT_FILES
  222.       IO_USER_CLASS = GO_USER_CLASS
  223.     CHANGING
  224.       CS_DATA       = ls_Data
  225.       CT_VALUES     = GT_VALUES
  226.     EXCEPTIONS
  227.       PRINT_CANCEL  = 1.
  228.   Case sy-subrc.
  229.     when 1.
  230.       Raise PRINT_CANCEL.
  231.   EndCase.
  232.  
  233.   endmethod.
  234.  
  235.  
  236. * <SIGNATURE>---------------------------------------------------------------------------------------+
  237. * | Instance Public Method YCLITC_PRINTED_FORM_TEMPLATE->SET_PARAMETERS
  238. * +-------------------------------------------------------------------------------------------------+
  239. * | [--->] I_FORM_NAME                    TYPE        YSITC_PRINTED_FORM_PARAMS-FORM_NAME(optional)
  240. * | [--->] I_FILE_NAME                    TYPE        YSITC_PRINTED_FORM_PARAMS-FILE_NAME(optional)
  241. * | [--->] I_FILE_LOCATION                TYPE        C(optional)
  242. * | [--->] I_PRINTDIALOG                  TYPE        C(optional)
  243. * | [--->] I_PROTECT                      TYPE        C(optional)
  244. * | [--->] I_OPTIMIZE                     TYPE        YSITC_PRINTED_FORM_PARAMS-OPTIMIZE(optional)
  245. * | [--->] I_DEBUG_MODE                   TYPE        C(optional)
  246. * | [--->] I_DECIMAL_SEPARATOR            TYPE        C(optional)
  247. * | [--->] I_CLOSE_FORM                   TYPE        C(optional)
  248. * | [--->] I_DELETE_FILE                  TYPE        C(optional)
  249. * | [--->] I_WITHOUT_OLE                  TYPE        C(optional)
  250. * | [--->] I_USE_JAR                      TYPE        C(optional)
  251. * | [--->] I_USE_UNICODE                  TYPE        C(optional)
  252. * | [--->] I_FORM_TYPE                    TYPE        CHAR30(optional)
  253. * +--------------------------------------------------------------------------------------</SIGNATURE>
  254.   method SET_PARAMETERS.
  255.   Data:
  256.     ls_Parameters type YSITC_PRINTED_FORM_PARAMS.
  257.  
  258.   If i_Form_Name is supplied.
  259.     gs_Parameters-Form_Name = i_Form_Name.
  260.   EndIf.
  261.   If i_File_Name is supplied.
  262.     gs_Parameters-File_Name = i_File_Name.
  263.     Shift gs_Parameters-File_Name left deleting leading Space.
  264.   EndIf.
  265.   If i_File_Location is supplied.
  266.     gs_Parameters-File_Location = i_File_Location.
  267.   EndIf.
  268.   If i_PrintDialog is supplied.
  269.     gs_Parameters-PrintDialog = i_PrintDialog.
  270.   EndIf.
  271.   If i_Protect is supplied.
  272.     gs_Parameters-Protect = i_Protect.
  273.   EndIf.
  274.   If i_Optimize is supplied.
  275.     gs_Parameters-Optimize = i_Optimize.
  276.   EndIf.
  277.   If i_Debug_Mode is supplied.
  278.     gs_Parameters-Debug_Mode = i_Debug_Mode.
  279.   EndIf.
  280.   If i_Decimal_Separator is supplied.
  281.     gs_Parameters-Decimal_Separator = i_Decimal_Separator.
  282.   EndIf.
  283.   If i_Close_Form is supplied.
  284.     gs_Parameters-Close_Form = i_Close_Form.
  285.   EndIf.
  286.   If i_Delete_File is supplied.
  287.     gs_Parameters-Delete_File = i_Delete_File.
  288.   EndIf.
  289.   If i_Without_Ole is supplied.
  290.     gs_Parameters-Without_Ole = i_Without_Ole.
  291.   EndIf.
  292.   If i_Use_Jar is supplied.
  293.     gs_Parameters-Use_Jar = i_Use_Jar.
  294.   EndIf.
  295.   If i_Use_Unicode is supplied.
  296.     gs_Parameters-Use_Unicode = i_Use_Unicode.
  297.   EndIf.
  298.  
  299.   If i_Form_Type is supplied.
  300.     gs_Parameters-Form_Type = i_Form_Type.
  301.   EndIf.
  302.  
  303.   endmethod.
  304.  
  305.  
  306. * <SIGNATURE>---------------------------------------------------------------------------------------+
  307. * | Instance Public Method YCLITC_PRINTED_FORM_TEMPLATE->SET_USER_CLASS
  308. * +-------------------------------------------------------------------------------------------------+
  309. * | [--->] IO_USER_CLASS                  TYPE REF TO OBJECT
  310. * +--------------------------------------------------------------------------------------</SIGNATURE>
  311.   method SET_USER_CLASS.
  312.   GO_USER_CLASS = IO_USER_CLASS.
  313.   endmethod.
  314. ENDCLASS.
Add Comment
Please, Sign In to add comment