Skip to Content
Author's profile photo Jahnavi Teja Venati

Get Boolean Expression details using BRF+ API’S in SAP and upload into application server

Hi Everyone,

  • Suppose if we require to display the expression name,GUID,last changed by,text of a Boolean expression in brf+ .

Let us take multiple Boolean expressions in BRF+ Application as shown below.

Here we have two Boolean expressions EXP_TEST_1 and EXP_TEST_2 in Z_BOL_TEST_w application.

/wp-content/uploads/2016/04/1_940798.png

  • Boolean expression (EXP_TEST_1)

To display the Boolean expression (EXP_TEST_1) details like Boolean expression name , Boolean expression GUID, Last changed by ,Text as shown in below screen shots.

/wp-content/uploads/2016/04/2_940880.png

/wp-content/uploads/2016/04/3_940881.png

  • Likewise for Boolean expression (EXP_TEST_2) we have following details shown in below screen shot.

/wp-content/uploads/2016/04/4_940883.png

/wp-content/uploads/2016/04/5_940885.png

  • Now we will use the following code to get Boolean expression details and upload those details in to Application server.
    *constants declarations

CONSTANTSgc_appl_id    TYPE if_fdt_types=>id  VALUE ‘005056C000081ED58ADDAB4AA60FF5F2’,

  gc_semi_colon    TYPE char01 VALUE ‘;’,

  gc_x                       TYPE char1     VALUE ‘X’,

  gc_csv                   TYPE string    VALUE ‘csv’.

*types declarations

TYPES: BEGIN OF ty_id,

                   id TYPE if_fdt_types=>id,

               END OF ty_id,

              BEGIN OF ty_boolean,

                 name         TYPE if_fdt_types=>name,

                 id               TYPE if_fdt_types=>id,

                 last_user TYPE syuname,

                 text           TYPE if_fdt_types=>text,

             END OF ty_boolean,

              tt_id TYPE  STANDARD TABLE OF  ty_id,

              tt_boolean TYPE  STANDARD TABLE OF ty_boolean.

*variable declarations

DATA: lref_boolean                 TYPE REF TO    if_fdt_boolean,

             lref_factory                  TYPE REF TO if_fdt_factory,

             lv_bol_id            TYPE if_fdt_types=>id,

             it_id TYPE STANDARD TABLE OF  ty_id,

             wa_id TYPE   ty_id,

             it_boolean TYPE STANDARD TABLE OF ty_boolean,

             wa_boolean TYPE ty_boolean,

             lv_last_chged_user TYPE syuname,

             lv_text TYPE if_fdt_types=>text,

             lv_name  TYPE if_fdt_types=>name.

*selection screen

SELECTION-SCREEN BEGIN OF BLOCK b1.

               SELECT-OPTIONS:s_bol_id FOR  lv_bol_id.

                PARAMETERS:p_file TYPE string.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

*for applicatin server file

   PERFORM get_appl_server_filepath_input CHANGING p_file.

START-OF-SELECTION.

*fill boolean ids from the select options

   LOOP AT s_bol_id WHERE option = ‘EQ’ AND sign =‘I’.

                       wa_idid  = s_bol_idlow.

                      APPEND wa_id TO it_id.

   ENDLOOP.

*generic factory instance

   lref_factory = cl_fdt_factory=>if_fdt_factory~get_instance( gc_appl_id ).

*generic factory instance

   lref_factory = cl_fdt_factory=>if_fdt_factory~get_instance( gc_appl_id ).

*get boolean details

   PERFORM boolean_details USING it_id

   CHANGING it_boolean .

* upload boolean details into application server file path

   PERFORM upload_boolean_data USING it_boolean

   p_file .

*f4 help for filepath

FORM get_appl_server_filepath_input

CHANGING p_ap_file TYPE string.

   DATA:l_title   TYPE  string.

   l_title = text001.

   CALL METHOD cl_rsan_ut_files=>f4

     EXPORTING

       i_applserv       = gc_x

       i_title          = l_title

       i_gui_extension  = gc_csv

       i_gui_ext_filter = gc_csv

     CHANGING

       c_file_name      = p_ap_file

     EXCEPTIONS

       failed           = 1

       OTHERS           = 2.

ENDFORM.                          “get_appl_server_filepath_input

*&———————————————————————*

*&      Form  boolean_details

*&———————————————————————*

*       text

*———————————————————————-*

*      –>PIT_IT       text

*      –>PIT_BOOLEAN  text

*———————————————————————-*

FORM boolean_details USING  pit_it TYPE tt_id

CHANGING pit_boolean TYPE tt_boolean.

**processing the boolean expression for details

   LOOP AT pit_it INTO wa_id.

     lref_boolean ?= lref_factory->get_expression(

     iv_id wa_idid ).

*get boolean name

     TRY.

         lref_boolean->if_fdt_admin_data~get_name(

         RECEIVING

         rv_name      lv_name

         ).

       CATCH cx_fdt_input .

         IF sysubrc EQ 0.

           MESSAGE text002 TYPE ‘I’.

         ENDIF.

     ENDTRY.

* get last changed user

     TRY.

         lref_boolean->if_fdt_admin_data~get_change_info(

         IMPORTING

         ev_change_user        = lv_last_chged_user

         ).

       CATCH cx_fdt_input.

         IF sysubrc EQ 0.

           MESSAGE text003 TYPE ‘I’.

         ENDIF.

     ENDTRY.

* get description

     lref_boolean->if_fdt_admin_data~get_texts(

     IMPORTING

     ev_text    =   lv_text

     ).

*Fill the boolean expression details

     wa_booleanname = lv_name.

     wa_booleanid   = wa_idid.

     wa_booleanlast_user = lv_last_chged_user.

     wa_booleantext    = lv_text.

     APPEND wa_boolean TO pit_boolean.

     CLEAR wa_boolean.

   ENDLOOP.

ENDFORM.                    “boolean_details

*&———————————————————————*

*&      Form  upload_boolean_data

*&———————————————————————*

*       text

*———————————————————————-*

*      –>PIT_BOOLEAN   text

*      –>PIV_FILENAME  text

*———————————————————————-*

FORM upload_boolean_data USING pit_boolean TYPE tt_boolean

piv_filename TYPE string.

   DATAwa_boolean_tmp TYPE ty_boolean,

   lv_var TYPE string.

   IF pit_boolean IS NOT INITIAL.

* open file

     OPEN DATASET piv_filename FOR OUTPUT IN TEXT MODE ENCODING  UTF8 .

     IF sysubrc EQ 0.

       LOOP AT pit_boolean INTO wa_boolean_tmp.

         CONCATENATE wa_boolean_tmpname

         wa_boolean_tmpid

         wa_boolean_tmplast_user

         wa_boolean_tmptext INTO lv_var SEPARATED BY gc_semi_colon.

         TRANSFER lv_var TO piv_filename.

       ENDLOOP.

       WRITE:‘Data uploaded successfully in Application server’.

     ENDIF.

*close file

     CLOSE DATASET piv_filename.

     CLEAR piv_filename.

   ENDIF.

ENDFORM.                    “upload_boolean_data

  • Provide multiple Boolean GUID’S and Application server file path then click on AL11 Files as shown below.

/wp-content/uploads/2016/04/6_940887.png

  • Choose any of the directories as shown in below screen shot.

/wp-content/uploads/2016/04/7_940888.png

  • Select any file and Copy file name as shown below.

/wp-content/uploads/2016/04/8_940889.png

  • Then Click execute.

/wp-content/uploads/2016/04/9_940890.png

  • We get the Following output.

/wp-content/uploads/2016/04/10_940891.png

  • Now open Tcode AL11 and open the filepath for the boolean expression details. Double click on filename ABC.CSV

/wp-content/uploads/2016/04/11_940895.png

  • We get following the boolean expression details from EXP_TEST_1 and EXP_TEST_2 Booleans.

/wp-content/uploads/2016/04/12_940896.png

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.