0 Replies Latest reply: Dec 12, 2012 11:37 PM by 647268 RSS

    PA_ALLOC_TARGET_LINES_PKG API to populate target.

    647268
      Can someone help me,

      My requirement is to populate Rule target line using API. targets are getting papulated using API but after population , Generate Allocation concurrent program error out.
      below is the steps.

      Same data if i am uploading using dataloader it's working fine. and PRC: Generate Allocations Transactions Concurrent program did not return any error. i tried the option of calling it through concurrent program but all in vain.


      Reproduction steps.

      1-     Populate PA_ALLOC_TARGET_LINES using PA_ALLOC_TARGET_LINES_PKG API
      2-     Execute PRC: Generate Allocations Transactions Concurrent program
      3-     Check the output. It is erroring. (error msg : 1-PA_AL_NO_BASIS_FOUND ,2-PA_AL_NO_TARGET_DETAILS , 3- PA_AL_LINE_PRCNT_NOT_100, 4-PA_AL_ALL_TASKS_RECD_ZERO_AMT)


      Script


      DECLARE
      lv_line_num number;
      x_rowid varchar2(1000);
      lv_h_rno number;
      lv_tmp_sum number;
      lv_rule_id number;
      lv_project_id number;
      lv_task_id number;
      l_LINE_PERCENT NUMBER;
      BEGIN
      fnd_global.apps_initialize(10882,52041,275);
      FOR CUR IN (SELECT *
      FROM xxfin.xxpa_pa_debug_cost_allc
      WHERE ORG_ID=1502
      AND PAYROLL_ID=73
      AND to_char(PAYROLL_EFFECTIVEDATE,'Mon-YY')='Nov-12'
      AND INCLUdE='Y'
      AND GL_COMPANY='0701'
      AND PTD_BALANCE <> 0
      AND rule_id in (404))
      LOOP
      SELECT NVL(MAX(LINE_NUM),0)+1
      INTO LV_LINE_NUM
      FROM PA_ALLOC_TARGET_LINES
      WHERE RULE_ID=CUR.RULE_ID;

      IF cur.task_id is not null
      and cur.prj_id is not null
      and cur.rule_id is not null THEN

      lv_rule_id := cur.rule_id;
      lv_project_id:=cur.prj_id;
      lv_task_id:=cur.task_id;

      lv_tmp_sum := nvl(lv_tmp_sum,0) + ROUND((cur.percentage * 100),5) ;

      l_LINE_PERCENT := ROUND((cur.percentage * 100),5);

      DBMS_OUTPUT.put_line('lv_Line_num--->Line Value:::->'||lv_Line_num||'--->'||l_LINE_PERCENT);

      PA_ALLOC_TARGET_LINES_PKG.INSERT_ROW (
      X_ROWID => X_ROWID,
      X_RULE_ID => cur.rule_id,
      X_LINE_NUM => lv_Line_num,
      X_PROJECT_ORG_ID => 1502, --ORG ID
      X_TASK_ORG_ID => NULL, --ORG ID
      X_PROJECT_TYPE => NULL,
      X_CLASS_CATEGORY => NULL,
      X_CLASS_CODE => NULL,
      X_SERVICE_TYPE => NULL,
      X_PROJECT_ID => cur.prj_id,
      X_TASK_ID => cur.task_id,
      X_EXCLUDE_FLAG => 'N',
      X_BILLABLE_ONLY_FLAG => 'N',
      X_LINE_PERCENT => l_LINE_PERCENT,
      X_CREATED_BY => 10882,
      X_CREATION_DATE => SYSDATE,
      X_LAST_UPDATE_DATE => SYSDATE,
      X_LAST_UPDATED_BY => 10882,
      X_LAST_UPDATE_LOGIN => 10882
      );
      commit;
      ELSE
      dbms_output.put_line('Project ID/Task ID/Rule ID these can not be null....!');
      END IF;
      END LOOP;

      DBMS_OUTPUT.put_line('Total Value:::->'||lv_tmp_sum);
      ------To make it 100%
      SELECT MAX(LINE_NUM)
      INTO LV_LINE_NUM
      FROM PA_ALLOC_TARGET_LINES
      WHERE RULE_ID=lv_rule_id;

      lv_tmp_sum:=(100 - lv_tmp_sum);

      DBMS_OUTPUT.put_line('Total l_LINE_PERCENT:::->'||l_LINE_PERCENT||'Line lv_tmp_sum'||lv_tmp_sum);

      update PA_ALLOC_TARGET_LINES set LINE_PERCENT= (l_LINE_PERCENT + lv_tmp_sum)
      where rule_id=lv_rule_id
      and line_num=LV_LINE_NUM;


      commit;

      lv_tmp_sum:=(100 - lv_tmp_sum);
      dbms_output.put_line('Babu .... '|| lv_tmp_sum);
      --- Status updating
      BEGIN
      update xxfin.xxpa_alloc_header
      set status='INTERFACED'
      WHERE h_rno=lv_h_rno;
      END;

      EXCEPTION WHEN OTHERS THEN NULL;
      END;