/sapapo/ts_dm_lock_unlock in background

Hi,
  I am using FM  /sapapo/ts_dm_lock_unlock to lock and unlock planning area.
When I am executing my program in forground it is working properly but in background by this FM planning area is not being lock/unlock
Can you please help on same FM in background.
Code written is as below
INCLUDE /sapapo/ts_constants_iobjnm.
" Declarations
TABLES :/SAPAPO/TSPAPLOB, " Planning Area - Plng Object Struct. (Key Fig)
/SAPAPO/TSVERSIO. " Planning Versions for Planning Area
" Selection Screen Design
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-B01.
SELECTION-SCREEN SKIP.
PARAMETERS :s_parea TYPE /SAPAPO/DM_PAREA_LOCK-PAREA OBLIGATORY, planning area
s_pvers TYPE /SAPAPO/VRSIOID OBLIGATORY, planning version
s_lock as CHECKBOX. Lock /unlock
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK BL1.
" Declarations
TYPES: BEGIN OF st_parea,
pareaid   TYPE /SAPAPO/TS_PAREAID,   " Planning area
keyfigure TYPE rsiobjnm,           " Key figure
END OF st_parea,
BEGIN OF st_pver,
pareaid TYPE /SAPAPO/TS_PAREAID,   " Planning area
VRSIOID TYPE /SAPAPO/VRSIOID,      " Planning version
END OF st_pver.
DATA: it_parea TYPE STANDARD TABLE OF st_parea, " Internal table
it_pver  TYPE STANDARD TABLE OF st_pver,
wa_parea TYPE st_parea,                  " Work area
wa_pver  TYPE st_pver.
DATA :lt_selection TYPE /sapapo/ts_iobj_selection_tab,
ls_selection TYPE /sapapo/ts_iobj_selection,
lS_LOCK_STR  TYPE /SAPAPO/TS_LC_LOCK_STR,
iv_lock     TYPE as4flag.
*DATA : version TYPE /sapapo/iobjnm  VALUE '000'.
" selecting values
SELECT pareaid vrsioid
FROM /SAPAPO/TSVERSIO
INTO TABLE it_pver
WHERE pareaid eq s_parea
AND vrsioid eq s_pvers.
IF sy-subrc = 0.
LOOP AT it_pver INTO wa_pver.
ls_selection-iobjnm = gs_c_iobjnm-version.
ls_selection-sign = 'I'.
ls_selection-option = 'EQ'.
ls_selection-low = wa_pver-vrsioid.
APPEND ls_selection TO lt_selection.
ENDLOOP.
ENDIF.
" If locking is selected
IF s_lock = 'X'.
CALL FUNCTION '/SAPAPO/TS_DM_LOCK_UNLOCK'
EXPORTING
iv_pareaid         = s_parea
iv_vrsioid         = s_pvers
iv_lock            = 'X'
* IMPORTING
*   EV_USER            =
*   ES_LOCK_STR        =
changing
ct_selection       = lt_selection
EXCEPTIONS
ERROR              = 1
OTHERS             = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
write: 3 s_parea ,15 ' Entered planning area has been locked'.
ENDIF.
" If unlocking
ELSEIF s_lock = ' '.
iv_lock = ' ' .
CALL FUNCTION '/SAPAPO/TS_DM_LOCK_UNLOCK'
EXPORTING
iv_pareaid         = s_parea
iv_vrsioid         = s_pvers
iv_lock            = ' '
*   IMPORTING
*     EV_USER            =
*     ES_LOCK_STR        = ls_lock_str
changing
ct_selection       = lt_selection
EXCEPTIONS
ERROR              = 1
OTHERS             = 2
iv_lock = ' ' .
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
write: 3 s_parea ,15 ' Entered planning area has been unlocked'.
ENDIF.
ENDIF.

solved

Similar Messages

  • Handle log from SNP optimizer (program /SAPAPO/RMDPLOPT)

    Hi gurus,
    I need to run program /SAPAPO/RMDPLOPT in background (easy part) but the log should be available through sm37 or in spool. I'm using FM OPEN_JOB + SUBMIT program VIA JOB + CLOSE_JOB but log isn't saved.
    ( I also tried with TO SAP-SPOOL, with EXPORTING LIST TO MEMORY + printing the list retrived)
    This program is using FG /SAPAPO/MSDP_LOG to manage the log. And before displaying it, program checks if sy-batch is initial --> that's why I dont have it on sm37
    I also checked that program /SAPAPO/RMDPLOPT has the following parameter in selection screen:
    4.1 DP_SNP_001: ProcessID for JobScheduling
      PARAMETERS p_procid TYPE rspc_instance NO-DISPLAY.
    It uses p_procid with FM /SAPAPO/MSDP_LOG_CREATE to create the log. After execution program call FM /SAPAPO/MSDP_LOG_SAVE, so I think log is saved in DB. My problem is that I dont know how to retrieve it.
    Could any of you give me any clue?
    Thanks in advance!

    Hi Kumar,
    Please find my below comments on your points.
    1)  /SAPAPO/TS_LCM_PLOB_DELTA_SYNC : This report is used to adjust the time-series objects.In the name of this report TS stands for Time Series, LCM stands for Management of Live-Cache/ LiveCache Management,PLOB stands for Planning Objects and SYNC stand for Synchronization.
    2) /SAPAPO/RMSDPDEP :  In this R stands for Report which is an executable program,,M stand for Material Management Application Area, SDP stands for Supply & Demand Planner
    which is nothing but package under which this report is developed, DEP stands for Deployment
    3) /SAPAPO/RMDPLOPT:  R stands for Report which is an executable program, M for Material Management which is an application area, DPL stands for Deployment and OPT stands for Optimizer.
    4) /SAPAPO/RSNPDRP1: R stands for Report which is an executable program,SNP stands for Supply network Planning, DRP stands for Demand Requirement Planning and for 1 I am also not sure why they added 1 behind this.
    I hope now at least for few of the above points, you are clear with naming conventions of standard reports in APO.
    Thanks,
    Saurabh

  • The error 600 occurred in the current database connection "LCA".

    Hi All,
    User is executing job /SAPAPO/TS_REALIGN_COPY in background,  as soon as the job is released its failing with runtime error:
    I check the Note 1126394 but not relevant.
    Runtime Errors         DBIF_DSQL2_SQL_ERROR
    Exception              CX_SY_NATIVE_SQL_ERROR
    Date and Time          18.08.2011 00:03:39
    Short text
         An SQL error occurred when executing Native SQL.
    What happened?
         The error 600 occurred in the current database connection "LCA".
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
    Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    How to correct the error
        Database error text........: "POS(1) Work rolled back: BAD_ALLOCATION in
         SAPTS_COPY_DA"
        Database error code........: 600
        Triggering SQL statement...: "EXECUTE PROCEDURE SAPTS_COPY_DATA"
        Internal call code.........: "[DBDS/NEW DSQL]"
        Please check the entries in the system log (Transaction SM21).
    If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "DBIF_DSQL2_SQL_ERROR" "CX_SY_NATIVE_SQL_ERROR"
        "/SAPAPO/SAPLOM_TIMESERIES" or "/SAPAPO/LOM_TIMESERIESU20"
        "/SAPAPO/OM_TS_DATA_COPY"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".
    Information on where terminated
        Termination occurred in the ABAP program "/SAPAPO/SAPLOM_TIMESERIES" - in
         "/SAPAPO/OM_TS_DATA_COPY".
        The main program was "/SAPAPO/TS_RLG_COPY_SINGLE ".
        In the source code you have the termination point in line 57
        of the (Include) program "/SAPAPO/LOM_TIMESERIESU20".
        The program "/SAPAPO/SAPLOM_TIMESERIES" was started as a background job.
        Job Name....... "/SAPAPO/TS_REALIGN_COPY"
        Job Initiator.. "CIBERNLAPO2"
        Job Number..... 00015100
        The termination is caused because exception "CX_SY_NATIVE_SQL_ERROR" occurred
         in
        procedure "/SAPAPO/OM_TS_DATA_COPY" "(FUNCTION)", but it was neither handled
         locally nor declared
        in the RAISING clause of its signature.
        The procedure is in program "/SAPAPO/SAPLOM_TIMESERIES "; its source code
         begins in line
        1 of the (Include program "/SAPAPO/LOM_TIMESERIESU20 ".
    Kindly suggest any notes or is any setting needs to be modified.
    Regards,
    Kaasi

    Hello Ada,
    the job was aborted due:
    Database error text........: "POS(1) Work rolled back: BAD_ALLOCATION in 
         SAPTS_COPY_DA"
        Database error code........: 600
        Triggering SQL statement...: "EXECUTE PROCEDURE SAPTS_COPY_DATA"
        Internal call code.........: "[DBDS/NEW DSQL]"
        Please check the entries in the system log (Transaction SM21).
    From the posted dump.
    Was it lack of OMS heap memory, memory leaking, program error or huge data selection for application run it's not clear. It will be best for SAP customer to create the SAP message and get SAP support when application canceled due Database error BAD_ALLOCATION in  LCA routine.
    Regards, Natalia Khlopina

  • Need to Lock Planning Area by using Enque and Deque Technique.

    Hi Experts,
    My problem is I have to lock the planning area till the Batch program complete and I have to unlock the planning area once the batch job is completed. if any one of the user is login  i.e. accessing planning book while batch job is running then batch job getting Failed.
    we can check the lock in SM12
    We have a custom program to send message to user to come out of the planning area but it does hit upto the mark.
    we are expecting some solution to lock and unlock the plannig area till the job completes.
    I was using some functional module to lock the planning area but it does not helped us. Kindly provide some help to acheive this situation
    The below functional modules I used to lock the Plannning area ZDP31. I have given the input while executing the Function module  PAREAID = ZDP31 (our Planning area Name)
    1) ENQUEUE_/SAPAPO/E_PAREA  
    2) /SAPAPO/TS_DM_LOCK
    3) /SAPAPO/TS_DM_UNLOCK_NEW
    4) /SAPAPO/TS_DM_LOCK_UNLOCK
    Please help me its in high prioity for us.

    Hello Balaji,
    Here are the needful function modules where you can use to lock the PA by enque & deque technique..
    a) ENQUEUE_READ Pass Planning Area value as GARG and PAREAID as GNAME to get information about lock entries for selected planning area.  GUNAME corresponding to GNAME = /SAPAPO/DM_PAREA_LOCK and GOBJ = /SAPAPO/E_PAREA entries provides user id (s) locking the planning area displayed in the field GTARG.
    b) TH_POPUP to send out popup messages to the users locking the Planning Area.
    c) TH_DELETE_USER to kick off users (GUNAME) who have been locking the planning area.
    I hope this helps...
    Cheers !!
    Regards
    Rahul Chitte

  • Product selection during TLB run with SCM 701 (EHP1)

    Dear All,
    We are on SCM 700 with EHP1.
    I have activated the business frame work function using txn: SFW5 - SCM_APO_DP_SNP_CTM to include the product selection during TLB run. But I observed that product selection has appeared only in the TLB run (txn: /SAPAPO/SNP04) for background selection but not in the Interactive TLB run (/SAPAPO/SNPTLB).
    How can get the product selection in Interactive TLB selection as well so that multiple planners can use the TLB sessions at the same time as long as products are not same.
    Please advise & thanks in advance
    Venkat DR

    Hello Venkat,
    I do not see the business function SCM_APO_DP_SNP_CTM when I open the txn SFW5. It only shows me enterprise business functions, which has ony CA, ERP, Financial functions. But not the ones I needed.
    Can you pls tell me how to see that function ? And why these functionalities given to be activated in SCM 7.0 ?
    Thanks
    Venkat

  • Error while running background deployment, program /SAPAPO/RMSDPDEP

    Hi all,
    For the second time in 3 months, I encounter this strange error while running a daily background deployment job, using program /SAPAPO/RMSDPDEP.
    The job starts correctly and does a part of its job, but then interrupt with this message in the job log :
      -->  "no valid simulation guid"  (class SAPAPO/OM_TS, n° 101)
      -->  "Unknown error"  (class SAPAPO/OM, n° 100)
      -->  "Job cancelled  after system exception ERROR_MESSAGE"  (class 00, n° 564)
    I just can't find any clue about what causes the problem...
    Did anyone encounter that kind of difficulties before ? Any help would be usefull...
    Thanks !
    Fabrice

    Hi Siva,
    In this range of time, I effectively run 13 parallel deployment jobs, as follow :
    n° 1, 2, 3, 4 and 5 : same location (factory 1) and each treats a products selection
    n° 6, 7, 8, 9 and 10 : same location (factory 2) and each treats a products selection
    n° 11 : all products of factory 3
    n° 12 : all products of factory 4
    n° 13 : all products of factory 5
    A product can only be produced in a single location, so there might not have access concurencies during parallel jobs. Do you think it could be some kind of a technical problem (not enough process available ?). Note that the problem can't come from CPU, we use CPU auto-allocation, and it works well.
    What do you think ?
    Thanks
    Fabrice

  • Delta Report (/sapapo/ccr) in the background

    Hi Gurus,
    Is it possible to execute /sapapo/ccr in the background which also includes automatically executing iteration in the background?
    I tried scheduling a job with /sapapo/cif_deltareport3 in the background, but it seems what it does is to only compare the data between the two systems. Is there a way that the iteration of the inconsistencies also be done in the background?
    Thanks in advance!

    Sabado,
    Unfortunately, iteration is only done during display. 
    You can set the iteration indicator for a batch run, but that only means that the re-compare will be done when you call up the results for review.
    It sounds like you are asking if the program can be made to re-compare the results an additional time, before saving.  The standard program will not do this.
    You can set the iteration flag in batch and save the results. When you then call up the results later, for review and action, this will have the effect that the iteration will be performed immediately prior to displaying the results.  Typically, then, less errors will be displayed for your users to resolve.  Time lag is typically insignificant.
    The volume of temporary inconsistancies can be reduced by executing the reconciliation report during the periods of least data transfers between APO and its connected systems.  Under these conditions, the requirement for iteration is reduced or eliminated.
    http://help.sap.com/saphelp_scm2007/helpdata/en/8e/1ed0c5e6dc724ba0731545fc48e7be/frameset.htm
    Regards,
    DB49

  • How to download output process receipt /SAPAPO/RRP4 using a background job.

    Hello,
    I am taking download for various location and product in the /SAPAPO/RRP4 , /SAPAPO/RRP1 or /SAPAPO/POV1.
    But as the size of the output data is very high, many times it loggs out.
    Can anybody suggest how to run this report in background ad take download.
    Regards

    Hi,
    We also had similar requirement and we have tried in many ways to set the job to run in background and to download the output but we failed. Then we developed the Z program using BAPIs with excel interface. You can use BAPI - BAPI_POSRVAPS_GETLIST3 to get the list and then filter as you require and download the put put using excel interface.
    It works.
    Regards
    Venkat

  • Message /SAPAPO/SDP_PAR023: "Some CVCs cannot be processed in block..."

    Hi,
    We are using SAP SCM release 5.1, the component Demand Planning. We are running macros in background jobs, e.g. a macro that populates a key figure by summarizing other key figures etc. We are using parallel processing, configured based on recommendation from SAP. When the number of CVCs to be processed by the macros becomes very high (we are processing ~300.000 CVCs at the moment), we get the following message in the job log in SM37:
    "Some CVCs cannot be processed in block 2 ", message number /SAPAPO/SDP_PAR023. Obviously the block number varies, and in our case we have had the above message for up to 19 blocks. Users have spotted CVC's that were not updated by the background job, but we don't have a specific list of the CVCs that were not processed.
    OSS notes mentioning this behaviour:
    Note 1282811 - Error processing 1 CVC, terminates the Parallel Profile
    Note 1501424 - DP Job with parallel processing - job status message
    Note 1494099 - DP Job with parallel processing - job status
    The question below is only to those who have encountered the same message in a DP background job:
    Did you find a log of the CVCs that were not processed, and what did you do to overcome the problem?
    Thanks in advance!
    Kind regards,
    Geir Kronkvist

    Hi Rico,
    Thanks for your reply! The spool consists of 23.145 pages so I looked for the word "Lock" using the "Find in request" in the "Spool request" menu. The searched found two entries where there was a message stating that a CVC was locked. It must be noted that no users are logged on while our background job is running, and there are no other processes (background or dialog) running in parallel. When checking transaction SM12 prior to running the job, there are no locks in the system.
    Our job schedule consists of a nightly process chain transferring data from BI to liveCache, and a monthly job that prepares historical data and calculates the forecast. We are now running the monthly job.
    Is it possible that the parallel processing may cause the locking by itself?
    Kind regards,
    Geir Kronkvist

  • Problem when I execute program SCM in background

    Hi experts,
        I am with problem when I execute a program (SCM) in background. I inserted a new field (estoque_seg(10)) and the process stopped at execute in background.When I call transaction and press F8, works but for this, I need jump the consistence  IF sy-batch IS INITIAL....Dont has any bath imput, only functions. Any idea?
    Follow below the code:
    Estrutura para tabela ENTRADA
    DATA: BEGIN OF st_entrada,
            matnr(40)            TYPE c,
            werks(20)            TYPE c,
            ponto_abas(10)       TYPE c,
            estoque_max(10)      TYPE c,
            cobertura(10)        TYPE c,
            estoque_seg(10)      TYPE c, " Erlon Lourenço 20/01/2011
          END OF st_entrada.
    Estrutura para tabela de LOG
    *TYPES: BEGIN OF st_saida,
           pernr(8)             TYPE c ,
           date(10)             TYPE c,
           er_contribuition(15) TYPE c,
           tax(15)              TYPE c,
           msg_erro(80)         TYPE c,
         END OF st_saida.
    Tabela para obter descricao da mensagem
    *DATA: ti_saida TYPE STANDARD TABLE OF st_saida WITH HEADER LINE
                                                  INITIAL SIZE 0.
    Tabela que recebera o arquivo texto
    DATA: BEGIN OF ti_entrada OCCURS 0.
            INCLUDE STRUCTURE st_entrada.
    DATA: END OF ti_entrada.
    DATA: BEGIN OF it_matid OCCURS 0,
      matnr TYPE /sapapo/matkey-matnr,
      matid TYPE /sapapo/matkey-matid,
    END OF it_matid.
    DATA: BEGIN OF it_locid OCCURS 0,
      locno TYPE /sapapo/loc-locno,
      locid TYPE /sapapo/loc-locid,
    END OF it_locid.
    DATA: BEGIN OF it_matlotsz OCCURS 0,
      target_dur TYPE /sapapo/matlotsz-target_dur,
      END OF it_matlotsz.
    DATA:        wa_matloc       LIKE /sapapo/matloc   OCCURS  0 WITH HEADER LINE,
                 wa_matlsim      LIKE /sapapo/matlsim  OCCURS  0 WITH HEADER LINE,
                 wa_matlotsz     LIKE /sapapo/matlotsz OCCURS  0 WITH HEADER LINE.
    Variáveis Globais
    DATA: v_tabix   TYPE sy-tabix,
          v_vrsioid TYPE /sapapo/apo01-vrsioid,
          v_tam     TYPE i.
        Select-Options & Parameters
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:  p_versao    TYPE /sapapo/apo01-vrsioex OBLIGATORY DEFAULT '000',
                 p_abas  AS CHECKBOX  ,
                 p_est   AS CHECKBOX  ,
                 p_cober AS CHECKBOX  ,
                 p_estsg AS CHECKBOX.   " ERLON LOURENCO - 20/01/2012 - Estoque Segurança
    SELECTION-SCREEN END OF BLOCK b1.
        Start-of-Selection
    START-OF-SELECTION.
      PERFORM consiste.
      PERFORM f_upload.
      PERFORM f_processa_batch.
      PERFORM f_saida_dados.
      MESSAGE i000 WITH 'Processo encerrado com Sucesso'.
    END-OF-SELECTION.
    *&      Form  F_UPLOAD
          text
    -->  p1        text
    <--  p2        text
    FORM f_upload .
      DATA: lc_file TYPE string.
      TYPES: BEGIN OF st_ent,
                cam(80),
             END OF st_ent.
      DATA: ti_ent TYPE STANDARD TABLE OF st_ent WITH HEADER LINE
                                                  INITIAL SIZE 0.
      RANGES: r_file       FOR zget0001-field_content.
      r_file[] = zbs_constantes=>obter( i_bukrs = space i_field = 'FILE' i_process = 'PONTO-REAB' ).
      READ TABLE r_file INDEX 1.
      lc_file = r_file-low.
      CLEAR: ti_entrada,
             ti_entrada[],
             ti_ent,
             ti_ent[].
    abrir arquivo para leitura
      OPEN DATASET lc_file FOR INPUT  IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        MESSAGE i000 WITH text-e01.
        STOP.
      ENDIF.
    Leitura de arquivos
      DO.
        READ DATASET lc_file INTO ti_ent.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND ti_ent.
      ENDDO.
    Fechamento do arquivo
      CLOSE DATASET lc_file.
      LOOP AT ti_ent.
        SPLIT ti_ent AT ';' INTO ti_entrada-matnr ti_entrada-werks ti_entrada-ponto_abas ti_entrada-estoque_max ti_entrada-cobertura ti_entrada-estoque_seg.
        APPEND ti_entrada.
      ENDLOOP.
    ENDFORM.                    " F_UPLOAD
    *&      Form  F_PROCESSA_BATCH
          text
    -->  p1        text
    <--  p2        text
    FORM f_processa_batch .
      LOOP AT ti_entrada.
        v_tabix = sy-tabix.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-matnr
          IMPORTING
            output = ti_entrada-matnr.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-ponto_abas
          IMPORTING
            output = ti_entrada-ponto_abas.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-estoque_max
          IMPORTING
            output = ti_entrada-estoque_max.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-cobertura
          IMPORTING
            output = ti_entrada-cobertura.
    IA - ERLON LOURENCO - 20/01/2012
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-estoque_seg
          IMPORTING
            output = ti_entrada-estoque_seg.
    FA - ERLON LOURENCO - 20/01/2012
        MODIFY ti_entrada INDEX v_tabix.
      ENDLOOP.
      CLEAR: it_matid,
             it_matid[],
             it_locid,
             it_locid[],
             wa_matlsim,
             wa_matlsim[],
             wa_matloc,
             wa_matloc[].
      SELECT matnr matid INTO TABLE it_matid FROM /sapapo/matkey
      FOR ALL ENTRIES IN ti_entrada WHERE matnr = ti_entrada-matnr.
      SELECT locno locid INTO TABLE it_locid FROM /sapapo/loc
      FOR ALL ENTRIES IN ti_entrada WHERE locno = ti_entrada-werks.
      IF p_versao = '000'.
        LOOP AT ti_entrada.
          READ TABLE it_matid WITH KEY matnr = ti_entrada-matnr.
          IF sy-subrc = 0 .
            READ TABLE it_locid WITH KEY locno = ti_entrada-werks.
            IF sy-subrc = 0.
              SELECT SINGLE * INTO wa_matloc FROM /sapapo/matloc WHERE matid = it_matid-matid  AND
                                                                       locid = it_locid-locid.
              IF sy-subrc = 0.
                IF p_abas = 'X'.
                  wa_matloc-reord    = ti_entrada-ponto_abas.
                ENDIF.
                IF p_est = 'X'.
                  wa_matloc-maxstock = ti_entrada-estoque_max.
                ENDIF.
                " IA - Erlon Lourenço - 23/01/2012
                if p_estsg = 'X'.
                  wa_matloc-safty    = ti_entrada-estoque_seg.     " Erlon Lourenço - 23/01/2012
                endif.
                "FA - Erlon Lourenço - 23/01/2012
                IF p_abas  = 'X'   OR
                   p_est   = 'X'   OR
                   p_estsg = 'X'.      " Erlon Lourenço - 23/01/2012
                  APPEND wa_matloc TO wa_matloc.
                ENDIF.
                SELECT SINGLE * INTO wa_matlotsz FROM /sapapo/matlotsz WHERE lszid = wa_matloc-lszid.
                IF sy-subrc = 0.
                  IF p_cober = 'X'.
                    wa_matlotsz-target_dur = ti_entrada-cobertura.
                    APPEND wa_matlotsz TO wa_matlotsz.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.   " LOOP AT ti_entrada.
      ELSE.
    Verifica versáo para saber se preenche a tabela wa_matlsim
        SELECT SINGLE vrsioid INTO v_vrsioid FROM /sapapo/apo01 WHERE vrsioex = p_versao.
        IF sy-subrc = 0.
          SELECT * INTO TABLE wa_matlsim FROM /sapapo/matlsim WHERE simid = v_vrsioid.
          IF wa_matlsim[] IS NOT INITIAL.
            LOOP AT ti_entrada.
              READ TABLE it_matid WITH KEY matnr = ti_entrada-matnr.
              IF sy-subrc = 0 .
                READ TABLE it_locid WITH KEY locno = ti_entrada-werks.
                IF sy-subrc = 0.
                  READ TABLE wa_matlsim WITH KEY matid = wa_matloc-matid
                                                 locid = wa_matloc-locid.
                  IF sy-subrc = 0.
                    wa_matlsim-reord    = ti_entrada-ponto_abas.
                    wa_matlsim-maxstock = ti_entrada-estoque_max.
                    wa_matlsim-safty    = ti_entrada-estoque_seg.     " Erlon Lourenço - 23/01/2012
                    MODIFY wa_matlsim INDEX v_tabix.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDLOOP.  " LOOP AT ti_entrada.
          ENDIF.     " IF wa_matlsim[] IS NOT INITIAL.
        ENDIF.     " IF sy-subrc = 0. 1º
      ENDIF.     "IF p_versao = '000'
    Funcáo que atualiza campos nas bases de dados.
      CALL FUNCTION '/SAPAPO/DM_PRODUCTS_POST'
        EXPORTING
          iv_vb         = 'U'
        TABLES
          it_matloc     = wa_matloc
          it_matlsim    = wa_matlsim
          it_matlotsz   = wa_matlotsz
        EXCEPTIONS
          not_qualified = 1
          insert_failed = 2
          update_failed = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " F_PROCESSA_BATCH
      FORM  BDC_DYNPRO
    *&      Form  F_SAIDA_DADOS
          text
    -->  p1        text
    <--  p2        text
    FORM f_saida_dados .
    IF ti_saida[] IS NOT INITIAL.
       DATA: lc_file TYPE string.
       lc_file = p_erros.
       CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
      BIN_FILESIZE                    =
           filename                        = lc_file
      FILETYPE                        = 'ASC'
         TABLES
           data_tab                        = ti_saida
      FIELDNAMES                      =
        EXCEPTIONS
          file_write_error                = 1
          no_batch                        = 2
          gui_refuse_filetransfer         = 3
          invalid_type                    = 4
          no_authority                    = 5
          unknown_error                   = 6
          header_not_allowed              = 7
          separator_not_allowed           = 8
          filesize_not_allowed            = 9
          header_too_long                 = 10
          dp_error_create                 = 11
          dp_error_send                   = 12
          dp_error_write                  = 13
          unknown_dp_error                = 14
          access_denied                   = 15
          dp_out_of_memory                = 16
          disk_full                       = 17
          dp_timeout                      = 18
          file_not_found                  = 19
          dataprovider_exception          = 20
          control_flush_error             = 21
          OTHERS                          = 22
       IF sy-subrc <> 0.
         MESSAGE i005 WITH 'Error to unload file !'.
         STOP.
       ENDIF.
    ENDIF.
    ENDFORM.                    " F_SAIDA_DADOS
    *&      Form  CONSISTE
          text
    -->  p1        text
    <--  p2        text
    FORM consiste .
      IF p_abas  IS INITIAL  AND
         p_est   IS INITIAL  AND
         p_cober IS INITIAL AND
         p_estsg IS INITIAL.   " ERLON LOURENCO - 20/01/2012 - Estoque Segurança
        MESSAGE i000 WITH text-e03.
        STOP.
      ENDIF.
      IF sy-batch IS INITIAL.
        MESSAGE i000 WITH text-e02.
        STOP.
      ENDIF.
    Best regards,
    Erlon Lourenço
    Edited by: Erlon Louren on Jan 27, 2012 11:09 AM

    Hi Raja,
                Check weather there are  any enhancements to the datasource.If yes once check the code in CMOD.Seems there is some discrepency in that.
    Regards
    Karthik

  • /SAPAPO/SDRQCR21 program is not working correctly if we run the program for range of material and plant wise

    Hi APO Experts,
    In our project, we have received more sales order inconsistencies which is not clearing by CCR program and it is clearing by  program /SAPAPO/SDRQCR21 with option as Build Reqmts from Doc. Flow, So We have decided to schedule the background job on daily basis for program /SAPAPO/SDRQCR21 with option as Build Reqmts from Doc. Flow, performing the testing in our quality system and observed the below strange behavior. 
    When I am running the program /SAPAPO/SDRQCR21 with Range of products and some location range with option as Build Reqmts from Doc. Flow, in Background job. In output it is suggesting to delete one sales order. If I checked that Sales order in ECC, it is for an different location, that is not part of my selection and the order is open. In MD04 the Qty is showing 1 ( as per sales order) but in APO RRP3 view the order qty is showing Zero. I have run the CCR, it is coming in different in content and if I push, the different is not going to APO.
    I have tried running the program /SAPAPO/SDRQCR21 with plant which is mentioned in that sales order with option as Build Reqmts from Doc. Flow, in Background job , it is suggesting this sales order under update option correctly.   
    Can you please help me understand why it is behaving differently like the location is not part of my selection and why it is suggesting the wrong action. And also whether is it advisable to run the /SAPAPO/SDRQCR21 with option as Build Reqmts from Doc. Flow at plant range and material range in background job.
    Thanks & Regards,
    Sundaram Radhakrishnan

    Sundaram,
    It sounds to me like the sales document records in the OLTP and in APO were created at different times.  This is common in Dev and Qual environments when the systems are commonly created at two different times, and each was a copy of an existing system that contained sales data.  The order number you see in //rrp3 is somewhat irrelevant; system generally uses the guid for many activities.
    FYI during Dev and Qual refreshes, if you are copying from a production environment that contains data, it is always best to create the OLTP and SCM images at the same time, and to copy them both to the Dev and Qual systems at the same time.  If you don't do this, you are faced with the additional tasks associated with getting the copied systems back into synch.
    If this is Dev or Qual, I suggest that you just completely wipe out all sales orders in APO and rebuild them using the CIF.
    If this is a mature production environment, the only time I have ever seen this issue is due to improperly created CIF enhancements.  Speak to your developers to find the root cause, and correct this problem.  Then, wipe out all sales orders and rebuild with CIF.
    Best Regards,
    DB49

  • Background job in APO does not start because of invalid user name

    Hello,
    I have a macro in a planning book and the /sapapo/cons_check program which a triggered via a background job. Now, I have problems with the start of the job:
    At the time the job was created inside SAP, an error occured. The job contains invalid values.
    The user name within the job does not exist any more.
    Now, I try to change the user name of the job (via step in sm37), but the error occured again.
    I have the possibility to create the invalid user name once again in su01.
    But I want to change the user name of the job - does somebody know how to do it?
    Thanks for your help!
    Kind regards
    Heinz

    Hello Heinz, this looks surprising.
    It's quite easy to change the user name in the SM37 job step, and we haven't faced issues with this.
    Could you check how many jobs are in either "scheduled" or in "released" status, and change steps for all of them? May be you changed the scheduled job, but the released job wasn't changed.
    Use your job name and give a search date as 1-2 years in the past, and around 1 month in the future. With this time horizon, you should most likely be able to capture all the relevant jobs having the same name that you are using.
    Now change the user name in step for all the jobs received above to be fully sure.
    One more trial could be to copy the current scheduled job to another job, modify the user name in this newly created job and then delete the old one.
    One of the above trials might possibly help you in some way, else its very tough to understand/explain your situation.
    Thanks - Pawan

  • Issue in background job for call transaction

    Dear All,
    I am facing a strange issue with call transaction. I need to add some Purchase requisitons in the APO using Call transactionmethod. It is working fine In All screen mode and No Screen Mode. But when I schedule the program in BAckground processing it is not wokring fine. It is not creating any Purchase requisitioins. When I debug the background Job it is creating Purchase requisitions.
    Please find the code below
        DATA: l_wa_params TYPE ctu_params.
        l_wa_params-dismode = l_c_mode.
        l_wa_params-updmode = 'A'.
        l_wa_params-defsize = 'X'.
        l_wa_params-racommit = 'X'.
        CALL TRANSACTION '/SAPAPO/RRP3' USING fp_i_bdcdata OPTIONS FROM l_wa_params
                                            MESSAGES INTO l_i_bdcmsgcoll.

    Hi,
    I have exactly the same problem with transaction /SAPAPO/RRP5.
    Thanks in advance for your help,
    Yannick CAREL

  • Internal error [/SAPAPO/OM_TS_TGRID_CREATE]

    Hi All,
    I am using  BAPI BAPI_PBSRVAPS_GETDETAIL to read live cache key figure. Its working finr when I execute the program in foreground and returns values but when I try executing this is background it gives me following error in Job Log:-
    Internal error [/SAPAPO/OM_TS_TGRID_CREATE].
    Can somebody suggest me the root cause and remedy for the same. I try doing planning area initializationa and live cache consistency check also but no luck.
    A timely reply will be highly appreciated.
    Thanks !
    Regards,
    Chandan

    Hi Chandan,
    I checked and found no sap notes similar to scm 4.0.  I would suggest to raise a OSS message to SAP so that they will advise on suitable support pack or sap note to implement.
    Regards
    R. Senthil Mareeswaran.

  • Error in TLB background job"Version does not exist"

    Hi Gurus,
    We are getting error of "Version does not exist " in TLB background run..The T-lane is between 2 DCs .we have checked everything but unfortunately
    we are not able to detect the root cause for the error.
    Your help will be appreciated.
    Thanks in advance
    Suyash

    Hi Suyash,
    I hope than your planning version is active!
    I also suppose than you have maintained mean of transport and products at Tr.Lanes level. 
    I think that you have some master data inconsistency in the version.
    Please run the reports; /SAPAPO/OM17, /SAPAPO/TSCONS, /SAPAPO/TSLCREORGSNP
    You can also run Model Consistency check (t.code /SAPAPO/CONSCHK). First you have to define the Model (t.code /SAPAPO/SCC07) and the Profile (t.code /SAPAPO/CONSPRF).
    Thanks, Marius

Maybe you are looking for

  • How do I find out what the EVENT CODES in the Printer Log mean?

    My C310A has some event codes in it Web page under TOOLS, EVENT LOG. Some it seems just indicate I printed out some reports. Others appear to be NETWORK RELATED?\ I have 69552, 74739, 74740, 74741, 74899 and 75900 showing. Can anyone point to a URL t

  • How to handle doubleclick mouse event in java

    i want to handle double click mouse event in java i use getClickCount() function but i want that on onetime click show othere windows and on doubleclick show diif. window but problem is that onetime is occuer always if u click doubleclick

  • Migrating DS 5.2 to ODSEE 11.1.1.5 using dsmig java error

    Problem Summary Migrating Sun Directory Server 5.2 to Oracle Directory Server 11.1.1.5 using dsmig fails Problem Description We are currently migrating our Sun DS 5.2 servers to ODSEE 11.1.1.5. I have successfully migrated one of our DS instances. Th

  • Problem with Trackpad on OSX Lion

    I just downloaded the OSX Lion. After 5 miutes of enjoying the new features, I undesrstood that I can't open the files on my desktop with 2 clicks. The same goes for my documents. I have to click 3 times in order to run them. All my work is on this c

  • Base DN in ACS 4.2

    Hi, I have ACS 4.2. After specific period, authentication fails until we restarts the ACS. So i want to ckeck the value of Base DN. What is Base DN? and How to check its value? Regards Gaurav