Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Background sheduling for Custom Tcode Using Call Transaction

surya_ramireddy
Participant
0 Kudos

Hi Experts.

A program has been developed to submit BDC using call transaction through a custom transaction . Its working fine in fore ground.

When i do background sheduling , its throwing as error like this.

Frontend function cannot be excuted in background

Job cancelled after system exception ERROR_MESSAGE

What could be the reason?

Regards,

surya.

13 REPLIES 13

Sm1tje
Active Contributor
0 Kudos

Where exactly does it fail? Post the relevant coding. Sounds like you want to perform some sort of frontend processing, which just will not work. Something like GUI_UPLOAD, CALL SCREEN or whatever.

0 Kudos

if the bdc( program B ) is using call transaction in 'A' mode and

when program A is executed in background.

it wont work right ?

I thin thats whta heppening here.

0 Kudos

Hi.

Here is my code. Can you tell me where its went on wrong?

REPORT Y_ISU_UPLOAD_TARIFF_CAL .

INCLUDE BDCRECXY.

DATA: BEGIN OF GT_ITAB OCCURS 0,

AB LIKE V_EANL-AB,

BIS LIKE V_EANL-BIS,

JOURNALCATCODE LIKE YCALCJOURNALCAT-JOURNALCATCODE,

ANLAGE LIKE V_EANL-ANLAGE,

END OF GT_ITAB.

DATA: BEGIN OF GT_LOG OCCURS 0,

VAR1 LIKE V_EANL-ANLAGE,

VAR2 TYPE CHAR060,

END OF GT_LOG.

DATA:LV_FILENAME TYPE STRING.

SELECTION-SCREEN BEGIN OF BLOCK ONE WITH FRAME TITLE TEXT-001.

PARAMETERS: P_FNAME TYPE RLGRAP-FILENAME.

SELECTION-SCREEN END OF BLOCK ONE.

AT SELECTION-SCREEN OUTPUT.

*---> At selection screen on value select

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

MASK = ',.csv,.*.'

MODE = '0'

TITLE = TEXT-002

IMPORTING

FILENAME = P_FNAME

EXCEPTIONS

OTHERS = 0.

START-OF-SELECTION.

PERFORM FILE_VALIDATION.

PERFORM FILE_UPLOAD.

PERFORM ADJUST_BDC.

PERFORM WRITE_LOG.

&----


*& Form FILE_VALIDATION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILE_VALIDATION .

LV_FILENAME = P_FNAME.

SEARCH LV_FILENAME FOR '.csv'.

IF SY-SUBRC = 4.

MESSAGE I000(YISU) WITH 'Please use csv file'.

EXIT.

ENDIF.

ENDFORM. " FILE_VALIDATION

&----


*& Form FILE_UPLOAD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILE_UPLOAD .

DATA: BEGIN OF LS_INP,

DATA(1000) TYPE C,

END OF LS_INP.

DATA: LT_INP LIKE TABLE OF LS_INP.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = LV_FILENAME

FILETYPE = 'ASC'

  • has_field_separator = ','

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = LT_INP

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT LT_INP INTO LS_INP.

SPLIT LS_INP-DATA AT ',' INTO

GT_ITAB-AB

GT_ITAB-BIS

GT_ITAB-JOURNALCATCODE

GT_ITAB-ANLAGE.

APPEND GT_ITAB.

CLEAR LS_INP.

ENDLOOP.

ENDFORM. " FILE_UPLOAD

&----


*& Form ADJUST_BDC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM ADJUST_BDC .

DATA:LT_MESSTAB TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,

LV_MSG(220) TYPE C,

LV_SUBRC TYPE SYSUBRC,

LV_TEXT(40) TYPE C,

LV_JOURNALNUM LIKE YCALC_RESULTS-JOURNALNUM ,

LV_MODE LIKE APQI-PUTACTIVE VALUE 'N',

LV_UPDATE LIKE APQI-PUTACTIVE VALUE 'L',

LV_CTU LIKE APQI-PUTACTIVE VALUE 'X',

LV_AB(8) TYPE C,

LV_BIS(8) TYPE C.

LOOP AT GT_ITAB.

CLEAR:LT_MESSTAB,LT_MESSTAB[],LV_SUBRC.

PERFORM BDC_DYNPRO1 USING 'SAPLYISU_TARIFF_CALCULATOR' '0100'.

PERFORM BDC_FIELD1 USING 'BDC_CURSOR' 'EANL-ANLAGE'.

PERFORM BDC_FIELD1 USING 'BDC_OKCODE' '=EXEC'.

PERFORM BDC_FIELD1 USING 'V_EANL-AB' GT_ITAB-AB.

PERFORM BDC_FIELD1 USING 'V_EANL-BIS' GT_ITAB-BIS.

PERFORM BDC_FIELD1 USING 'YCALCJOURNALCAT-JOURNALCATCODE' GT_ITAB-JOURNALCATCODE.

PERFORM BDC_FIELD1 USING 'EANL-ANLAGE' GT_ITAB-ANLAGE.

PERFORM BDC_DYNPRO1 USING 'SAPLYISU_TARIFF_CALCULATOR' '0200'.

PERFORM BDC_FIELD1 USING 'BDC_OKCODE' '=CAL'.

PERFORM BDC_FIELD1 USING 'BDC_CURSOR' 'YCALCJOURNALCAT-JOURNALCATCODE'.

PERFORM BDC_DYNPRO1 USING 'SAPLYISU_TARIFF_CALCULATOR' '0200'.

PERFORM BDC_FIELD1 USING 'BDC_OKCODE' '=SAV'.

PERFORM BDC_TRANSACTION TABLES LT_MESSTAB

USING 'YPR01'

LV_CTU

LV_MODE

LV_UPDATE.

LOOP AT LT_MESSTAB.

IF LT_MESSTAB-MSGTYP CA 'AEX'.

LV_SUBRC = 1001.

EXIT.

ELSE.

LV_SUBRC = 0.

ENDIF.

ENDLOOP.

IF LV_SUBRC EQ 0.

CLEAR:LV_AB,LV_BIS.

CONCATENATE GT_ITAB-AB4(4) GT_ITAB-AB2(2) GT_ITAB-AB+0(2) INTO

LV_AB.

CONCATENATE GT_ITAB-BIS4(4) GT_ITAB-BIS2(2) GT_ITAB-BIS+0(2) INTO

LV_BIS.

CLEAR:LV_JOURNALNUM.

SELECT SINGLE JOURNALNUM FROM YCALC_RESULTS INTO LV_JOURNALNUM

WHERE JOURNALBEG EQ LV_AB AND

JOURNALEND EQ LV_BIS AND

JOURNALINST EQ GT_ITAB-ANLAGE AND

JOURNALCAT EQ GT_ITAB-JOURNALCATCODE.

IF SY-SUBRC EQ 0.

CONCATENATE 'Journal Saved with no:' LV_JOURNALNUM INTO LV_TEXT.

CLEAR:GT_LOG.

GT_LOG-VAR1 = GT_ITAB-ANLAGE.

GT_LOG-VAR2 = LV_TEXT.

APPEND GT_LOG.

CLEAR LV_TEXT.

ENDIF.

ELSE.

LOOP AT LT_MESSTAB.

CLEAR:LV_MSG.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = LT_MESSTAB-MSGID

  • LANG = '-D'

NO = LT_MESSTAB-MSGNR

V1 = LT_MESSTAB-MSGV1

V2 = LT_MESSTAB-MSGV2

V3 = LT_MESSTAB-MSGV3

V4 = LT_MESSTAB-MSGV4

IMPORTING

MSG = LV_MSG.

CLEAR:GT_LOG.

GT_LOG-VAR1 = GT_ITAB-ANLAGE.

GT_LOG-VAR2 = LV_MSG.

APPEND GT_LOG.

ENDLOOP.

ENDIF.

ENDLOOP.

ENDFORM. " ADJUST_BDC

----


  • Start new screen *

----


FORM BDC_DYNPRO1 USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "BDC_DYNPRO1

----


  • Insert field *

----


FORM BDC_FIELD1 USING FNAM FVAL.

  • IF fval <> NODATA_CHARACTER.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

  • ENDIF.

ENDFORM. "BDC_FIELD1

&----


*& Form WRITE_LOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM WRITE_LOG .

LOOP AT GT_LOG.

WRITE:/ GT_LOG-VAR1, 15 GT_LOG-VAR2.

ENDLOOP.

ENDFORM. " WRITE_LOG

Regards,

surya.

0 Kudos

Hi Micky.

The short dump was due to gui_upload. Thanks for your reply. Now changed logic to get the files from application server.

Again i got short dump when i run the same program in background. that is to do BDC for custom Tcode which has been developed using ABAP OOPS concept. Here i am giving the details of shor dump. Can you help me out?

A RAISE statement in the program "CL_GUI_CUSTOM_CONTAINER=======CP" raised the

exception

condition "CNTL_ERROR".

Since the exception was not intercepted by a superior program

in the hierarchy, processing was terminated.

Regards,

surya.

0 Kudos

You cannot use GUI classes in background.

Edited by: ksd on Dec 4, 2009 4:46 PM

0 Kudos

Hi Micky.

Here complete shot dump code. Its throwing expection in the class CL_GUI_CUSTOM_CONTAINER .

The termination occurred in the ABAP program "CL_GUI_CUSTOM_CONTAINER=======CP"

in "CONSTRUCTOR".

The main program was "SAPLYISU_TARIFF_CALCULATOR ".

The termination occurred in line 62 of the source code of the (Include)

program "CL_GUI_CUSTOM_CONTAINER=======CM001"

of the source code of program "CL_GUI_CUSTOM_CONTAINER=======CM001" (when

calling the editor 620).

The program "CL_GUI_CUSTOM_CONTAINER=======CP" was started as a background job.

Error occurred during batch input processing

SOURCE CODE EXTRACT:

000500 CALL METHOD SET_VISIBLE

000510 EXPORTING

000520 VISIBLE = '1'

000530 EXCEPTIONS

000540 CNTL_SYSTEM_ERROR = 1

000550 CNTL_ERROR = 2.

000560

000570 CASE SY-SUBRC.

000580 WHEN 0.

000590 WHEN 1.

000600 RAISE CNTL_SYSTEM_ERROR.

000610 WHEN 2.

> RAISE CNTL_ERROR. (EXPECTION OCCURED HERE)000630 WHEN OTHERS.

000640 RAISE CNTL_ERROR.

000650 ENDCASE.

000660

0 Kudos

Save The File in tab delimitted text file in the system and read internal content of the file using following part of code .

I hope this will resolve your concern

*&---------------------------------------------------------------------*
*& AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file
*&---------------------------------------------------------------------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file."File path you have given in the selection screen
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
      field_name    = ' '
    IMPORTING
      file_name     = p_file.

*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*

START-OF-SELECTION.
  v_file = p_file.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = v_file " file path of your tabdelimitted file in the system
      filetype                = 'ASC'
      has_field_separator     = 'X'
    TABLES
      data_tab                = it_cust "The internal table where you are uploading the data
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc = 0.
  ENDIF.

0 Kudos

Hi ksd.

I the following code from your thred.

<b> IF R_CONTROL IS INITIAL.

  • Check whether the program is run in batch or foreground

IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.

  • Run in foreground

CREATE OBJECT R_CONTROL EXPORTING CONTAINER_NAME = 'CONTAINER_1'.

CREATE OBJECT R_GRID EXPORTING I_PARENT = R_CONTROL.

ELSE.

  • Run in background

CREATE OBJECT R_GRID EXPORTING I_PARENT = G_DOCK.

ENDIF.</b>

My query is where can i mention the name of contaniner in docking container.

can you give me detail steps?

Regards,

surya.

0 Kudos

HI ksd.

The following code has been used but still giving the same short dump in docking contaniner class as well.

IF G_RESULT_CONTAINER IS INITIAL.

IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.

  • Run in foreground

CREATE OBJECT G_RESULT_CONTAINER

EXPORTING

CONTAINER_NAME = 'G_RESULT_CONTAINER'.

CREATE OBJECT G_GRID

EXPORTING

I_PARENT = G_RESULT_CONTAINER.

ELSE.

  • Run in background

CREATE OBJECT G_DOCK

EXPORTING

NAME = 'G_RESULT_CONTAINER'.

CREATE OBJECT G_GRID EXPORTING I_PARENT = G_DOCK.

ENDIF.

ENDIF.

Regards,

surya.

0 Kudos

to know about docking container

check link:[http://sapprograms.blogspot.com/2008/12/alv-listbox-on-selection-screen-using.html]

0 Kudos

solved on my own.

0 Kudos

Hi Surya,

I am facing this same issue with CL_GUI_CUSTOM_CONTAINER=======CP. Could you please provide the steps you performed to solve this issue?

Regards,

Mike

kesavadas_thekkillath
Active Contributor
0 Kudos

Use session method.