Skip to Content
In my last blog {code:html}Dynamic File Name using XI 3.0 SP12 Part – I{code} we have seen the scenario like how to use the JCO call in the message mapping level and get the numbers to be used for the file name generation. This time we’ll go in detail on how to use the dynamic file name generation using the *XSLT mapping with Java enhancement* another exit which SAP has provided in XI.   We’ll consider the same scenario as used in Part-I but in this case will be using XSLT mapping in the place of message mapping which can be achieved as follows:  h3. Prerequisites   Assuming that the following have been done and configured.  1. The SAP JCo configuration files has been downloaded from SAP Service Marketplace  (http://service.sap.com/connectors) and have been configured with the appropriate CLASSPATH in the local PC where the java code is being compiled as per the instructions.    2.A value table has been created in the ABAP stack of the WAS in which XI is running and the entries as the file types, which will be written into the files are maintained. 3.Create a number range object in SNRO transaction in the same ABAP stack which will be having the sub objects as the file types maintained in the value table with their number ranges maintained. h3. Step1  Creation of the RFC function module in the ABAP stack through transaction SE37 with the *Remote-Enabled Module* option checked and *Start Immediately* option chosen in the attributes of this FM. image  This function module will have an import parameter FILETYPE which is of type CHAR10 and it will have a export parameter FILENAME which is of type CHAR10 and will have the file name with the dynamic name concatenated.  *Source Code for the RFC Function Module: * FUNCTION zrfc_file_numbers.  *”—- —————————————————– *”*”Local Interface: *”  IMPORTING *”     VALUE(FILETYPE) TYPE  CHAR10  *”  EXPORTING *”     VALUE(FILENAME) TYPE  CHAR10 *”—- —————————————————– DATA: length TYPE i,       temp_lastno_ch(10),       temp_subobj(3),       temp_fname(10). CONSTANTS: c_nr_range_nr(1) VALUE ‘1’,            c_nr_object(6)   VALUE ‘ZTEST1’. IF NOT filetype IS INITIAL.    temp_subobj = filetype+0(3).    CALL FUNCTION ‘NUMBER_GET_NEXT’    EXPORTING         nr_range_nr                   = ‘1’         object                        = ‘ZTEST1’ *       QUANTITY                      = ‘1’         subobject                     = temp_subobj *       TOYEAR                        = ‘0000’ *       IGNORE_BUFFER                 = ‘ ‘    IMPORTING         number                        = temp_lastno_ch *       QUANTITY                      = *       RETURNCODE                    =    EXCEPTIONS         interval_not_found            = 1         number_range_not_intern       = 2         object_not_found              = 3         quantity_is_0                 = 4         quantity_is_not_1             = 5         interval_overflow             = 6         buffer_overflow               = 7         OTHERS                        = 8.    IF sy-subrc EQ 0.       SHIFT temp_lastno_ch LEFT DELETING LEADING ‘0’.       length = STRLEN( temp_lastno_ch ).       CLEAR: temp_fname(10).       CASE length.         WHEN ‘1’.          CONCATENATE ‘PN00000’ temp_lastno_ch           INTO temp_fname.          MOVE temp_fname TO filename.   WHEN ‘2’.  CONCATENATE ‘PN0000’ temp_lastno_ch   INTO temp_fname.  MOVE temp_fname TO filename.  WHEN ‘3’.  CONCATENATE ‘PN000’ temp_lastno_ch   INTO temp_fname.  MOVE temp_fname TO filename.          WHEN ‘4’.          CONCATENATE ‘PN00’ temp_lastno_ch           INTO temp_fname.          MOVE temp_fname TO filename.         WHEN ‘5’.          CONCATENATE ‘PN0’ temp_lastno_ch           INTO temp_fname.          MOVE temp_fname TO filename.         WHEN ‘6’.          CONCATENATE ‘PN’ temp_lastno_ch           INTO temp_fname.          MOVE temp_fname TO filename.       ENDCASE.     ENDIF.   ELSE. *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO *           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.   ENDIF. ENDFUNCTION.  h3. Step2  h3. Integration Repository Here in this folder select all these three files and make a zip/jar file by giving the *absolute path info* if winzip is being used so that when it is opened with Winzip will view as follows. image  d) Create an imported archive in the namespace in which the development is going on in Integration Directory as follows and import the zip file created in the above mentioned step. image   e)Create an interface mapping by choosing the mapping type as XSL as shown below and activate all the integration directory objects. image image   On testing of the interface mapping will provide the result screen as follows: image
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply