top of page

ABAP code for the program that will create dynamic prompt file on the application server

*&---------------------------------------------------------------------*

*& Report ZBPC_DAILY_BACKUP_PROMPT

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT ZBPC_DAILY_BACKUP_PROMPT.

*&---------------------------------------------------------------------*

*& Report ZBPC_PROMPT1

*&---------------------------------------------------------------------*

*& Program to create a dynamic prompt file for BPC backup routines which will be executed

*& by program UJD_TEST_PACKAGE

*& Written by Peter Warren  peter.warren@biconsultancysolutions.com   9 Aug 2018

*&---------------------------------------------------------------------*

*set up variables

data: endmessage(100),TEXT2(20) type c.

data: lv_string(250) type c.

data: fname(60).

data: TEXT1 type string.

  DATA: ld_day TYPE c.

* Call function to get the day number using the system date sy-datum

  CALL FUNCTION 'DATE_COMPUTE_DAY'

       EXPORTING

            date = sy-datum

       IMPORTING

            day  = ld_day.

* Depending on the value returned to ld_day which will be a value from 1 to 7 - create a name for the output file which is different each day.

CASE ld_day.

WHEN '1'.

TEXT2 = 'MONDAY.CSV'.

WHEN '2'.

TEXT2 = 'TUESDAY.CSV'.

WHEN '3'.

TEXT2 = 'WEDNESDAY.CSV'.

WHEN '4'.

TEXT2 = 'THURSDAY.CSV'.

WHEN '5'.

TEXT2 = 'FRIDAY.CSV'.

WHEN '6'.

TEXT2 = 'SATURDAY.CSV'.

WHEN '7'.

TEXT2 = 'SUNDAY.CSV'.

WHEN OTHERS.

MESSAGE '...' TYPE 'E'.

TEXT2 = 'NAMING OF FILE FAILED'.

ENDCASE.

 

* Now create the variable part of the %SELECTION% parameter which will pick differing values of the category dimension depending on what month number is in the system date sy-datum 2 characters starting from position 4

*Note the values created by BPC for the %SELECTION% prompt are preceded by

*/%APPSET%/%APP%/PRIVATEPUBLICATIONS/%USER%/TempFiles/FROM.TMP  but you can drop this and just use the bit from @@@SAVE onwards

CASE sy-datum+4(2).

  WHEN '01'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_12,FCST_01|'.

  WHEN '02'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_01,FCST_02|'.

  WHEN '03'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_02,FCST_03|'.

 WHEN '04'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_03,FCST_04|'.

  WHEN '05'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_04,FCST_05|'.

  WHEN '06'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_05,FCST_06|'.

 WHEN '07'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_06,FCST_07|'.

  WHEN '08'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_07,FCST_08|'.

  WHEN '09'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_08,FCST_09|'.

 WHEN '10'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_09,FCST_10|'.

  WHEN '11'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_10,FCST_11|'.

  WHEN '12'.

    TEXT1 = '@@@SAVE@@@@@@EXPAND@@@|DIMENSION:CATEGORY|FCST_11,FCST_12|'.

  WHEN OTHERS.

    MESSAGE '...' TYPE 'E'.

ENDCASE.

 

*Now join the parts together and make sure that you insert a horizontal_tab between the parameter name and its value and also put a CR_LF at the end of each line.

Concatenate:'%SELECTION%' cl_abap_char_utilities=>horizontal_tab TEXT1 CL_ABAP_CHAR_UTILITIES=>CR_LF '%OUTPUTFILE%' cl_abap_char_utilities=>horizontal_tab TEXT2 CL_ABAP_CHAR_UTILITIES=>CR_LF INTO lv_string.

fname = '/usr/sap/trans/BPC_PROMPT.txt'.

OPEN DATASET fname FOR OUTPUT IN TEXT MODE encoding default.

transfer lv_string to fname.

close dataset fname.

Concatenate:fname '  created sucessfully backup file will be called  -   ' TEXT2 into endmessage.

write endmessage.

bottom of page