Cycles lock in background job of program RKGALKSV5

Hello All,
Can we enter more than 1 cycle on the selection screen field (where it says ' Enter Cycles')  when we execute program RKGALKSV5 (Actual Distribution)? In the same job, can we enter more than 1 cycle for this program? We are getting locks for cycle run group 0000 and the first cycle entered (the variant has 3 cycles). Does anyone else have same issue?
Appreciate your help!
Thanks,
Suma

Hello Ravi,
Thanks for the help.
I looked at the note Note 416507 - ALLOCATION: Troubleshooting guide. I did not find any relevant information regarding the locks in cycles. The exact error message I am getting is 'Cycle XXXXXXXXXX 01/01/2007 cannot be started because run group 0000 is locked.' - Error message GA 562.
I checked couple of SAP notes. Note 70094 - ALLOCATION: lock problem during background processing and Note 967372 - New GL or SL allocation: explaining the lock concept.
Both the notes explained the lock concept either between cycles running for different company codes or cycles running for different cycle run groups within the same company code. But in our system, we have only one company code and default cycle run group 0000 and only 1 job which executes 3 cycles in the program RKGALKSV5.
So I had a question, if we can run 3 cycles in the same program, in a single job, for a default cycle run group 0000 within the same company code.
Thanks,
Suma

Similar Messages

  • Error in background job for program RSGET_SMSY error message No active job

    Hello!
    I would like to set up the Change Request Management functionality in SAP Solution Manager.
    The only red warning by executing Test-button in Tcode “SOLAR_ADMIN_PROJECT” is:
    <b>Error in background job for program RSGET_SMSY error message No active job found</b>
    Can someone please tell me how to solve this problem?
    (tcodes, technical steps)
    Thank you very much!
    regards
    Thom

    Thank you very much!
    Can you also help me with the warning "Errors occurred during synchronization of the system landscape" in tcode SOLAR_PROJECT_ADMIN" --> System landscape --> Change requests --> "Refresh"?
    The second issue I cannot see any projects in Tcode "/TMWFLOW/CMSCONF"
    according to the SPRO-step "Set Project Assignment of Requests as Mandatory"
    Thank you!
    regards

  • Problems creating background job for program (job open, submit and close)

    Hi gurus,
    im trying to start a background job using the FM BP_START_DATE_EDITOR to show the start date to the job or if it's imediate. this FM it's working fine, after call it im opening a job, submiting it and call the job close FM and the job close FM creates me the job.
    The problem it's when i go to the sm37 to see the job status the job has been canceled, and the job log says that i have to give a start date to the job.
    What i dont understand it's either the job is imediate or i choose a date to start the job always gives me this error...
    Below goes my code,
    any ideas will be rewarded
      CLEAR: stdt_modify_type, stdt_output.
      CALL FUNCTION 'BP_START_DATE_EDITOR'
           EXPORTING
                stdt_dialog                    = 'Y'
                stdt_input                     = stdt_input
                stdt_opcode                    = 14
           IMPORTING
                stdt_modify_type               = stdt_modify_type
                stdt_output                    = stdt_output
           EXCEPTIONS
                fcal_id_not_defined            = 1
                incomplete_last_startdate      = 2
                incomplete_startdate           = 3
                invalid_dialog_type            = 4
                invalid_eventid                = 5
                invalid_opcode                 = 6
                invalid_opmode_name            = 7
                invalid_periodbehaviour        = 8
                invalid_predecessor_jobname    = 9
                last_startdate_in_the_past     = 10
                no_period_data_given           = 11
                no_startdate_given             = 12
                period_and_predjob_no_way      = 13
                period_too_small_for_limit     = 14
                predecessor_jobname_not_unique = 15
                startdate_interval_too_large   = 16
                startdate_in_the_past          = 17
                startdate_is_a_holiday         = 18
                startdate_out_of_fcal_range    = 19
                stdt_before_holiday_in_past    = 20
                unknown_fcal_error_occured     = 21
                no_workday_nr_given            = 22
                invalid_workday_countdir       = 23
                invalid_workday_nr             = 24
                notbefore_stdt_missing         = 25
                workday_starttime_missing      = 26
                no_eventid_given               = 27
                OTHERS                         = 28.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        MOVE 'X' TO gv_flag.
      ENDIF.
      DATA jobname LIKE tbtcjob-jobname.
      DATA jobcount LIKE tbtcjob-jobcount.
      DATA job_release LIKE  btch0000-char1.
      DATA job_imediate TYPE c.
      CLEAR: jobname, jobcount, job_release.
      CONCATENATE 'MAPAEXEC' sy-uname sy-datum
                   INTO jobname SEPARATED BY space.
      CALL FUNCTION 'JOB_OPEN'
           EXPORTING
                jobname          = jobname
           IMPORTING
                jobcount         = jobcount
           EXCEPTIONS
                cant_create_job  = 1
                invalid_job_data = 2
                jobname_missing  = 3
                OTHERS           = 4.
      IF sy-subrc <> 0.
        MESSAGE i003(zmapas).
        EXIT.
      ENDIF.
      SUBMIT z_mapa_execucao_orcamental
             VIA JOB jobname NUMBER jobcount
             WITH ano EQ ano
             WITH so_perio IN so_perio
             WITH so_date IN so_date
             WITH so_org EQ so_org
             WITH so_num IN so_num
             AND RETURN.
      IF stdt_output-startdttyp EQ 'I'.
        CLEAR job_imediate.
        job_imediate = 'X'.
      ENDIF.
      CALL FUNCTION 'JOB_CLOSE'
           EXPORTING
                calendar_id                 = stdt_output-calendarid
                event_id                    = stdt_output-eventid
                event_param                 = stdt_output-eventparm
                event_periodic              = stdt_output-periodic  "?
                jobcount                    = jobcount
                jobname                     = jobname
                laststrtdt                  = stdt_output-laststrtdt
                laststrttm                  = stdt_output-laststrttm
                prddays                     = stdt_output-prddays  "??
                prdhours                    = stdt_output-prdhours  "?
                prdmins                     = stdt_output-prdmins  "??
                prdmonths                   = stdt_output-prdmonths
                prdweeks                    = stdt_output-prdweeks  "?
                predjob_checkstat           = stdt_output-checkstat
                pred_jobcount               = stdt_output-predjobcnt
                pred_jobname                = stdt_output-predjob
                sdlstrtdt                   = stdt_output-sdlstrtdt
                sdlstrttm                   = stdt_output-sdlstrttm
                strtimmed                   = job_imediate
                targetsystem                = stdt_output-instname
                start_on_workday_not_before = stdt_output-notbefore
                start_on_workday_nr         = stdt_output-wdayno
                workday_count_direction     = stdt_output-wdaycdir
           IMPORTING
                job_was_released            = job_release
           EXCEPTIONS
                cant_start_immediate        = 1
                invalid_startdate           = 2
                jobname_missing             = 3
                job_close_failed            = 4
                job_nosteps                 = 5
                job_notex                   = 6
                lock_failed                 = 7
                OTHERS                      = 8.
      IF sy-subrc <> 0.
        MESSAGE i003(zmapas).
        EXIT.
      ELSE.
        MESSAGE i004(zmapas) WITH jobname.
      ENDIF.
    Thanks in advance,
    Best Regards
    João Martins

    Hello João.
    In debug mode, check the value of variables you passed to parameters sdlstrtdt and sdlstrttm.
    As aditional info, I usually achieve your goal without FM BP_START_DATE_EDITOR.
    Check this code:
    CALL FUNCTION 'JOB_OPEN'
          EXPORTING
               jobname          = w_jobname
          IMPORTING
               jobcount         = w_jobcount
          EXCEPTIONS
               cant_create_job  = 1
               invalid_job_data = 2
               jobname_missing  = 3
               OTHERS           = 4.
    CHECK sy-subrc = 0.
    CLEAR seltab_wa.
    MOVE: t_jobs-param TO seltab_wa-selname,
    t_processar-line+34 TO seltab_wa-low.
    APPEND seltab_wa TO seltab.
    seltab_wa-selname = 'P_LOJA'.
    seltab_wa-low = t_processar-ficheiro+7(4).
    APPEND seltab_wa TO seltab.
    *** Submete o programa para o JOB
    SUBMIT (t_jobs-repid)
      WITH  SELECTION-TABLE seltab
      USER sy-uname
       VIA JOB w_jobname NUMBER w_jobcount
       AND RETURN.
    *** Encerra o JOB
      l_hora = sy-uzeit.
      ADD 60 TO l_hora.
    CALL FUNCTION 'JOB_CLOSE'
       EXPORTING
          jobcount           = w_jobcount
          jobname           = w_jobname
          sdlstrtdt            = sy-datum
          sdlstrttm           = l_hora
          targetserver       = w_servidor
       IMPORTING
          job_was_released     = l_liberado
       EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          OTHERS               = 8.
    Regards.
    Valter Oliveira.

  • Pass lock to background job

    Hi,
    I'm looking for ideas.
    We have an inbound process for special messages transfered from XI system via asynchrounous call. Messages are identified by a GUID.
    The inbound process will save the messages in a database table and create background jobs for processing big messages while small messages are processed directly.
    To avoid any interference, we want to lock messages as long as they are processed. For this we have a lock object and the Enqueue/dequeue modules.
    Now my question is: How can I pass a lock to the background job (created by SUBMIT VIA JOB) and have it released there after processing is done. The Job will run in a new LUW.
    And then, if any error in background (or online) processing occurs, how to make sure all existing locks are released?
    Thanks for some good ideas on how to proceed.
    Regards,
    Clemens

    resolved - we won't do it. We'll create some kind of queue: A fully-buffered database table where we put the lock entries and remoce them when it's time to do so. This way we can integrate an activity monitor watching the objects being processed.
    Thanks for reading
    Clemens

  • Starting Background Job from program...

    Hello I am using following to create a background job.
      DATA: number TYPE tbtcjob-jobcount,
            name TYPE tbtcjob-jobname VALUE 'METZ: INVOICING FROM SHIPMENT',
            print_parameters TYPE pri_params.
      data vari  LIKE varid-variant.
      data shipm    LIKE vttk-tknum.
      data use  LIKE   btch2170-username.
      vari = '3350_1' .
      shipm = p_shipment.
      use = 'K5_BATCH'.
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = name
        IMPORTING
          jobcount         = number
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
      IF sy-subrc = 0.
        SUBMIT Z5L_START_INVOICING with p_shipm = shipm
                                   with p_vari = vari
                                   with p_submit = 'X'
                                   USER use VIA JOB name NUMBER number
                                   and return.
        IF sy-subrc = 0.
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              jobcount             = number
              jobname              = name
              strtimmed            = 'X'
            EXCEPTIONS
              cant_start_immediate = 1
              invalid_startdate    = 2
              jobname_missing      = 3
              job_close_failed     = 4
              job_nosteps          = 5
              job_notex            = 6
              lock_failed          = 7
              OTHERS               = 8.
          IF sy-subrc <> 0.
          ENDIF.
        ENDIF.
      ENDIF.
    I am using the addition USER but the job gets started with user who is log on or who is using this trasaction.
    It should start with user 'K5_BATCH' but it is not...........
    Please help........
    Edited by: Alvaro Tejada Galindo on Apr 7, 2008 1:00 PM

    I found the following info:
    Open Job Scheduling Without Dialog (Including COMMIT WORK)
    Use JOB_OPEN to create a background job.  The function module returns the unique ID number which, together with the job name, is required for identifying the job.
    Once you have "opened" a job, you can add job steps to it with JOB_SUBMIT and submit the job for processing with JOB_CLOSE.
    I think you will first have to use the JOB_SUBMIT  statement like mentioned above

  • Background Job BICCMS_111_20100526* (program RSBATCH_EXECUTE_PROZESS)

    Dear Friends,
    We are using BI 7 system.
    We have restarted the system few days back.
    After the restart we have observed that there is a job running for every hour.
    The job name starts with BICCMS_111_20100526* (It is executing a program called program RSBATCH_EXECUTE_PROZESS)
    The Job log displays the below messages:
    Job started
    Step 001 started (program RSBATCH_EXECUTE_PROZESS, variant &0000000207130, user ID ALEREMOTE)
    Process chain COMMUNITIES_NEWSLETTER has status "G" (log ID 2AN8LZN1DCCFF9WLZPITD5ZL7)
    Process chain COMMUNITIES_NEWSLETTER has status "G" (log ID D3VZG4S9FEZHZ2KVD0CV9PGFF)
    Process chain COMMUNITIES_NEWSLETTER has status "G" (log ID B0LDW40H15U898R2RWYX1HJZF)
    It is executing a program (RSBATCH_EXECUTE_PROZESS) which is checking the status of the each process chains multiple times.
    The job is occupying the system resources quite frequently and affecting the data loads.
    Could you please let us know what is this Job doing ?
    How to stop this Job (Not able to stop it in SM37) ?
    What are the consequences of stoping this Job ?
    Thanks,
    Ram.

    Hi Rama,
    Thank you for the reply.
    The problem here is i am not able to find the scheduled/released job with that name.
    I have stopped the active job (SM37) and i have killed the work process (SM50) many times which is just stopping the current active job.
    But after an hour time the job is again getting executed.
    Thanks,
    Ram.

  • Background job - Customised program

    Hi all,
    I write ABAP program to download text file to our local system.
    I need to setup daily (automatically) run this program, how to setup ?
    pls advise
    Thanks,
    Sankaran

    Hi
    Ur program should be executable program.U can schedule periodically in Tx SM36.
    Here enter ur job name,click on start up ,in the pop up click on date/time,Here give ur first date/time and in bottom of the pop up screen click periodically check box.Then select daily radio button.
    Gopi

  • Submitting a updates in a prog to a background job

    Hello everyone,
    I am generating a alv report with production orders.In the toolbar i created a button for updating data.When i select some production orders in the alv list and select the button then transaction co02 is called and some updates are done.I done that the updating by using bdc recording and the updates are working fine.
    But my problem is
    1. when the user selects the updates button in the toolbar these updates should take place via. a background job.
    2. Before submitting the background job the program needs to check if a version of a prog is running,the check should look for the prog name and the triggering user, if a match is found the user should receive a error message.
    3. If a match is not found then the background job should be scheduled immediately and should be created with a name of prog name and the triggering user.
    I need to these steps,can anyone please give me a sample code for this.
    Thank you.
    dp.

    The approach I would probably take for this would be:
    1. Write the records that need processing to a "Z" table from the ALV, and delete these back out (or mark as "done") once processed by the batch job.
    2. It is possible to check for a batch job name and its status, but I've usually found an easier and more reliable way is to use a lock object to check this e.g. you could use and existing object such as ESRDIRE with a dummy lock argument such as 'CO02_IS_LOCKED' .  The batch job should contain code to set the enqueue... if this enqueue fails it means another job / program is already processing the requests so this instance can stop, otherwise the batch program can continue the CO02 processing.  In other words, you are creating a doorway through which only one instance of the job can pass at a time.
    3. A couple of easy ways to do this are (a) event triggered jobs, wherein you define the job and have it fire up when an event is raised (e.g. by calling function BP_EVENT_RAISE) or (b) use the SIMPLE_BATCH_JOB_SUBMIT (which calls the JOB_OPEN, JOB_SUBMIT, JOB_CLOSE functions for you).
    Jonathan

  • Submitting a update in a porg to a background job?

    Hello everyone,
    I am generating a alv report with production orders.In the toolbar i created a button for updating data.When i select some production orders in the alv list and select the button then transaction co02 is called and some updates are done.I done that the updating by using bdc recording and the updates are working fine.
    But my problem is
    1. when the user selects the updates button in the toolbar these updates should take place via. a background job.
    2. Before submitting the background job the program needs to check if a version of a prog is running,the check should look for the prog name and the triggering user, if a match is found the user should receive a error message.
    3. If a match is not found then the background job should be scheduled immediately and should be created with a name of prog name and the triggering user.
    I need to these steps,can anyone please give me a sample code for this.
    Thank you.
    dp.

    The approach I would probably take for this would be:
    1. Write the records that need processing to a "Z" table from the ALV, and delete these back out (or mark as "done") once processed by the batch job.
    2. It is possible to check for a batch job name and its status, but I've usually found an easier and more reliable way is to use a lock object to check this e.g. you could use and existing object such as ESRDIRE with a dummy lock argument such as 'CO02_IS_LOCKED' .  The batch job should contain code to set the enqueue... if this enqueue fails it means another job / program is already processing the requests so this instance can stop, otherwise the batch program can continue the CO02 processing.  In other words, you are creating a doorway through which only one instance of the job can pass at a time.
    3. A couple of easy ways to do this are (a) event triggered jobs, wherein you define the job and have it fire up when an event is raised (e.g. by calling function BP_EVENT_RAISE) or (b) use the SIMPLE_BATCH_JOB_SUBMIT (which calls the JOB_OPEN, JOB_SUBMIT, JOB_CLOSE functions for you).
    Jonathan

  • Error when running SWN_SELSEN as background job.

    Hello Gurus,
    I am facing a typical problem these days.
    The background job for program SWN_SELSEN is scheduled in every 5 mins. It has started to fail intermittently with the error message 'An instance of the report SWN_SELSEN is still active'. But the stange thing is that the program completes its execution in approx. 12 - 15 secs  then why this kind of error it is throwing.
    This error message should not come as the program completes itself in 12- 15 secs and it has more than 4 mins as free time.
    Please help as this kind of failure is happenning quite frequently i.e. once in nearly every three times it executes. In a day around 100 times.
    Please help.
    Thanks in advance.
    Neha

    Hello,
    I assume you've checked in SM37 to see how often it actually runs and whether perhaps two instances have been scheduled?
    Also check the log in SLG1 to see if there is any clue there.
    regards
    Rick Bakker
    Hanabi Technology

  • Use "grid display" for background job of RM07DOCS / MB51

    Hello experts,
    When you execute program RM07DOCS with transaction MB51, it uses a "hierarchy display" for the output, a list of material documents. User can then use the menus for "Goto>Detail List" and the display changes to a "grid display".
    If we define a background job for program RM07DOCS with a variant, the program uses the "hierarchy display". Is it possible to use "grid display" instead?  do we need to call a different program?
    Thanks.
    Raul V

    Hi Raul,
    Copy standard program RM07DOCS to ZRM07DOCS
    Then add this code "PERFORM detail_list."
    before the code "CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' "
    This will solve your problem.
    Regards.

  • Regarding Background Job Abort using

    Hi ,
    I am using FM BP_JOB_ABORT to abort background jobs through program,but it taking longtime to cancel background jobs in SM37 after exectuing FM BP_JOB_ABORT in program..
    will i have to write  any statement in program after this  FM BP_JOB_ABORT to cancel the background job immediately through program..
    Awaiting for valuable suggestion..
    Regards
    Anil

    Hi,
    I looking for FM to cancel background jobs quikly through program..
    Regards
    Anil

  • Background job link with the cycle

    Hello experts
    We are running the background job XXXX to run the distribution cycle. can anyone let me know where this job is having the link to the cycle which needs to be executed.
    meanwhile please explain me about the functionality of the program RKALWAIT.
    Regards

    Jay,
    seems data in the TBTCPV view was corrupted .. try to re-define the failing jobs thru SM36 or SM37 ..
    for RDDIMPDP -- in SE38--> Run RDDNEWPP program to re-define the Job.
    -K

  • It has an error when run a program in background job

    Dear Expert,
    we have a program
    when run it in background,it has a error "Error during import of clipboard contents" but when run it normally(run in front workbench se38 or run the t-code),everything is ok.i've used typingJDBG in the command box to debuge the background job,there has no error.
    whould you like to tell me what had happen? thanks a lot!
    addition: the program used a function ALSM_EXCEL_TO_INTERNAL_TABLE
    Thanks & Regards,
    Kerry
    Edited by: Kerry Wang on Aug 24, 2009 2:12 PM
    Edited by: Kerry Wang on Aug 24, 2009 2:14 PM
    Edited by: Kerry Wang on Aug 24, 2009 2:14 PM

    Hi,
      You cannot use FMs to get data directly from the presentation server when program is executed in the backgroud.
    Check the thread : GUI_DOWNLOAD
    Regards,
    Himanshu

  • Failed to Run OLE Excel program in background JOB (SM36)

    Please help.
    I have write a program to use OLE to create a Excel file.
    The program can run successful in front end workstation. However, when I run the program in background job by SM36.
    The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
    How can I solve it ?
    Can OLE Excel be run on background job ?
    Thanks so much,
    Mark

    Hi Mark:
    Your need is a very common one. I also was asked to generate an Excel in Background.
    It is not possible to work with OLE in background mode.
    The reason is: In background mode there is no presentation server. OLE is executed in presentation server.
    Below I paste the code I wrote to solve my problem.
    This class sends a mail with an excel attached. The Excel content will be the internal table you pass to the class. But the Excel is not binary, it is a plain text file, separated by tabulators. Anyway, when you open it with Excel, the columns are properly shown.
    Sorry. Comments are in spanish, I don't have time to translate it.
    I kindly ask to everybody which want to use it to keep my name in the code.
    * Autor: Jordi Escoda, 30/10/2008.
    * Descripción: Esta clase genera un correo electrónico destinado a
    *  una persona, adjuntando el contenido de una tabla interna como
    *  Excel (campos separados por tabuladores).
    *  La virtud de esta clase es su sencillez de utilización. Para lanzar
    *  el mail con el excel adjunto basta con declarar la tabla interna,
    *  llenarla, colocar el asunto del mensaje, el destinatario, el nombre
    *  del excel adjunto, y pasar la tabla interna.
    * Ejemplo de utilización:
    *  DATA: lc_mail TYPE REF TO cl_mail_builder_xls_attach.
    *  DATA: lt_anla TYPE STANDARD TABLE OF anla.
    *    SELECT * INTO TABLE lt_anla  FROM anla.
    *    CREATE OBJECT lc_mail.
    *    CALL METHOD lc_mail->set_subject( 'Excel adjunto' ).
    *    CALL METHOD lc_mail->set_recipient( 'XXX@XXXDOTCOM' ).
    *    CALL METHOD lc_mail->set_attach_filename( 'ANLA' ).
    *    APPEND 'Cuerpo del mensaje' TO  lt_body.
    *    APPEND 'Saludos cordiales' TO  lt_body.
    *    CALL METHOD lc_mail->set_bodytext( lt_body ).
    *    CALL METHOD lc_mail->set_attach_table( lt_anla ).
    *    CALL METHOD lc_mail->send( ).
    *       CLASS cl_mail_builder_xls_attach DEFINITION
    CLASS cl_mail_builder_xls_attach DEFINITION.
      PUBLIC SECTION.
        METHODS: set_subject
                               IMPORTING im_subject TYPE so_obj_des,
                 set_bodytext
                               IMPORTING im_body TYPE bcsy_text,
                 set_recipient
                               IMPORTING im_recipient TYPE ad_smtpadr,
                 set_attach_table
                               IMPORTING im_table TYPE ANY TABLE,
                 set_attach_filename
                               IMPORTING im_attach_name TYPE sood-objdes,
                 send.
      PRIVATE SECTION.
        CONSTANTS:
          c_tab  TYPE c VALUE cl_bcs_convert=>gc_tab,
          c_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf,
          c_singlequote TYPE c VALUE '.
        DATA: l_recipient_addr TYPE ad_smtpadr.
        DATA: send_request   TYPE REF TO cl_bcs,
              document       TYPE REF TO cl_document_bcs,
              recipient      TYPE REF TO if_recipient_bcs,
              bcs_exception  TYPE REF TO cx_bcs.
        DATA: binary_content TYPE solix_tab,
              size           TYPE so_obj_len.
        DATA: l_string TYPE string,
              l_body_text TYPE bcsy_text,
              l_subject TYPE so_obj_des,
              l_attach_name TYPE sood-objdes.
        METHODS: create_binary_content,
                 get_dataelement_medium_text
                        IMPORTING im_table_name TYPE tabname
                                  im_field_name TYPE fieldname
                        EXPORTING ex_medium_text TYPE scrtext_m.
    ENDCLASS.                    "cl_mail_builder_xls_attach DEFINITION
    *       CLASS cl_mail_builder_xls_attach IMPLEMENTATION
    CLASS cl_mail_builder_xls_attach IMPLEMENTATION.
      METHOD set_bodytext.
        l_body_text[] = im_body[].
      ENDMETHOD.                    "add_bodytext
      METHOD set_subject.
        l_subject = im_subject.
      ENDMETHOD.                    "add_subject
      METHOD set_attach_filename.
        l_attach_name = im_attach_name.
      ENDMETHOD.                    "add_subject
      METHOD set_recipient.
        l_recipient_addr = im_recipient.
      ENDMETHOD.                    "add_subject
      METHOD set_attach_table.
    *   Rellena en un string el contenido de la tabla interna recibida
        DATA: ref_to_struct  TYPE REF TO cl_abap_structdescr.
        DATA: my_like TYPE fieldname,
              nombretabla TYPE tabname,
              nombrecampo TYPE fieldname,
              texto_mediano TYPE scrtext_m.
        DATA: l_idx TYPE i,
              l_valorcampo(16) TYPE c,
              l_long TYPE i.
        FIELD-SYMBOLS: <fs_linea> TYPE ANY,
                       <fs_campo> TYPE ANY.
        FIELD-SYMBOLS: <comp_descr> TYPE abap_compdescr.
        CHECK NOT im_table[] IS INITIAL.
    *   Línea con los nombres de las columnas.
        CLEAR l_string.
        LOOP AT im_table ASSIGNING <fs_linea>.
    *     Toma los atributos del componente
          ref_to_struct  =
                     cl_abap_structdescr=>describe_by_data( <fs_linea> ).
          LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
            ASSIGN COMPONENT <comp_descr>-name
                                OF STRUCTURE <fs_linea> TO <fs_campo>.
    *       Obtenemos el origen de donde proviene (like). Ej:BKPF-BUDAT
            DESCRIBE FIELD <fs_campo> HELP-ID my_like.
            SPLIT my_like AT '-' INTO nombretabla nombrecampo.
            CALL METHOD get_dataelement_medium_text
              EXPORTING
                im_table_name  = nombretabla
                im_field_name  = nombrecampo
              IMPORTING
                ex_medium_text = texto_mediano.
            IF texto_mediano IS INITIAL.
              CONCATENATE l_string <comp_descr>-name INTO l_string.
            ELSE.
              CONCATENATE l_string texto_mediano INTO l_string.
            ENDIF.
            AT LAST.
              CONCATENATE l_string c_crlf INTO l_string.
              EXIT.
            ENDAT.
            CONCATENATE l_string c_tab INTO l_string.
          ENDLOOP.
          EXIT.
        ENDLOOP.
    *   Contenido de la tabla
        LOOP AT im_table ASSIGNING <fs_linea>.
    *     Toma los atributos del componente
          ref_to_struct  =
                     cl_abap_structdescr=>describe_by_data( <fs_linea> ).
          LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
    *       Asignamos el componente ue tratamos, para obtener
    *       el valor del mismo
            ASSIGN COMPONENT <comp_descr>-name OF STRUCTURE <fs_linea>
                                            TO <fs_campo>.
            CASE <comp_descr>-type_kind.
              WHEN 'P'. "Packed Number
    *           Convierte a caracter
                WRITE <fs_campo> TO l_valorcampo.
                CONCATENATE l_string l_valorcampo INTO l_string.
              WHEN OTHERS.
                l_long = STRLEN( <fs_campo> ).
                IF l_long > 11 AND <fs_campo> CO ' 0123456789'.
    *             El Excel muestra un número tal como 190000000006
    *             en formato 1,9E+11.
    *             Para eviarlo, los números de más de 11 dígitos los
    *             concatenamos con comillas simples.
                  CONCATENATE l_string c_singlequote
                              <fs_campo> c_singlequote INTO l_string.
                ELSE.
                  CONCATENATE l_string <fs_campo> INTO l_string.
                ENDIF.
            ENDCASE.
            AT LAST.
    *         Añade CRLF
              CONCATENATE l_string c_crlf INTO l_string.
              EXIT.
            ENDAT.
    *       Añade tabulador
            CONCATENATE l_string c_tab INTO l_string.
          ENDLOOP.
        ENDLOOP.
        create_binary_content( ).
      ENDMETHOD.                    "set_attach_table
      METHOD create_binary_content.
        DATA: l_size TYPE so_obj_len.
    *   convert the text string into UTF-16LE binary data including
    *   byte-order-mark. Mircosoft Excel prefers these settings
    *   all this is done by new class cl_bcs_convert (see note 1151257)
        TRY.
            cl_bcs_convert=>string_to_solix(
              EXPORTING
                iv_string   = l_string
                iv_codepage = '4103'  "suitable for MS Excel, leave empty
                iv_add_bom  = 'X'     "for other doc types
              IMPORTING
                et_solix  = binary_content
                ev_size   = size ).
          CATCH cx_bcs.
            MESSAGE e445(so).
        ENDTRY.
      ENDMETHOD.                    "create_binary_content
      METHOD send.
        DATA: l_sent_to_all TYPE os_boolean.
        TRY.
    *       create persistent send request
            send_request = cl_bcs=>create_persistent( ).
    *       create and set document with attachment
    *       create document object
            document = cl_document_bcs=>create_document(
              i_type    = 'RAW'
              i_text    = l_body_text
              i_subject = l_subject ).
    *       add the spread sheet as attachment to document object
            document->add_attachment(
              i_attachment_type    = 'xls'
              i_attachment_subject = l_attach_name
              i_attachment_size    = size
              i_att_content_hex    = binary_content ).
    *       add document object to send request
            send_request->set_document( document ).
    *       add recipient (e-mail address)
            recipient =
               cl_cam_address_bcs=>create_internet_address(
                                          l_recipient_addr ).
    *       add recipient object to send request
            send_request->add_recipient( recipient ).
    *       send document
            l_sent_to_all = send_request->send(
                                 i_with_error_screen = 'X' ).
            COMMIT WORK.
            IF l_sent_to_all IS INITIAL.
              MESSAGE i500(sbcoms) WITH l_recipient_addr.
            ELSE.
              MESSAGE s022(so).
            ENDIF.
          CATCH cx_bcs INTO bcs_exception.
            MESSAGE i865(so) WITH bcs_exception->error_type.
        ENDTRY.
      ENDMETHOD.                    "lcl_mail_xls_attachment
      METHOD get_dataelement_medium_text.
        DATA: lt_fld_info TYPE STANDARD TABLE OF dfies,
          wa_fld_info TYPE dfies.
    *   Busca en el diccionario los datos del campo
        CALL FUNCTION 'DDIF_FIELDINFO_GET'
          EXPORTING
            tabname        = im_table_name
            fieldname      = im_field_name
            langu          = sy-langu
          TABLES
            dfies_tab      = lt_fld_info
          EXCEPTIONS
            not_found      = 1
            internal_error = 2
            OTHERS         = 3.
        CLEAR ex_medium_text.
        IF sy-subrc = 0.
          READ TABLE lt_fld_info INDEX 1 INTO wa_fld_info.
    *     Si lo ha podido tomar del diccionario...
          IF NOT wa_fld_info-scrtext_m IS INITIAL.
    *       Toma el nombre del nombre de campo del diccionario
            ex_medium_text = wa_fld_info-scrtext_m.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "get_dataelement_medium_text
    ENDCLASS.                    "cl_mail_builder_xls_attach IMPLEMENTATION

Maybe you are looking for