Skip to Content

SAP APO Upgrade issue

Hi All,

I am working in APO Upgrade project where in , change is required to move from PPM to PDS data structures. Unable to find equivalent tables of PPM to PDS conversion . Tables in PPM are following.. need to replace these..

/sapapo/plan

/sapapo/planact

/sapapo/compalt

I am trying to replace the following code with PDS data structure..

SELECT SINGLE dactid epar1

FROM /sapapo/matmap AS a

JOIN /sapapo/trprod AS b ON amatid = bmatid

JOIN /sapapo/plan AS c ON bplanid = cplanid

JOIN /sapapo/planact AS d ON cplanid = dplanid

JOIN /sapapo/compalt AS e ON bamatid = eamatid

AND bmatid = ematid

INTO (lv_actid, lv_per)

WHERE a~ext_matnr = it_matkey-ext_matnr

AND b~valto >= lv_today "still valid

AND b~trptype = '002' "PPM

AND b~beskz = 'E' "int.production

AND c~cost1 = 10 "preferred line

AND c~state = '1' "plan active

Please let me know if this is possible through tables or using FM /SAPAPO/PPM_GET_PLAN.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Dec 22, 2008 at 11:54 AM

    Found the answer to the solution

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      Solution is to use the BAPI "BAPI_PDSSRVAPS_GETLIST" which gives PDS equivalent of PPM data structures.

      The internal tables lt_pds_head , lt_pds_component , lt_pds_activity etc in BAPI holds all

      the data equivalent to PPM data structure.

      This BAPI can be tested independetly by passing

      LOGICAL_SYSTEM as current APO system and

      PRODUCT_SELECTION as range which contains PRODUCT details and

      LOCATION_SELECTION as range which contains LOCATION details and

      PLANNING_VERSION as '000' (ACTIVE VERSION) and

      PLAN_USAGE as 'S' .

      The sample code is as below :

      METHOD if_ex_smod_apocf005~exit_/sapapo/saplcif_prod_001.

      *******************************************************************************

      • Program ID : CIF_IMPORT Helpdesk ID: PPDS4 *

      • Description: This methid is copied from User Exit ZXCIFUSERU08 for mapping *

      • the data structures within the program to adapt BADI tables. *

      *

      ********************************************************************************

      • Revision History *

      *******************************************************************************

      • Date : Changed By : *

      • Revision ID: Helpdesk ID: *

      • Description: *

      ********************************************************************************

      DATA: lv_baserate TYPE zbaserate,

      lv_rate TYPE /sapapo/bcap1,

      lv_per TYPE /sapapo/par1,

      lv_qty TYPE /sapapo/par1,

      lv_actid TYPE /sapapo/actid,

      lv_resid TYPE /sapapo/resid,

      lv_ndpen_ord TYPE /sapapo/snpndpend,

      lv_ndpen_fc TYPE /sapapo/snpndpend,

      lv_ndpen_ordc TYPE /sapapo/snpndpend, "component ND penalty

      lv_ndpen_fcc TYPE /sapapo/snpndpend, "component ND penalty

      lv_today TYPE /sapapo/scc_valtotstmp,

      ls_matloc TYPE /sapapo/cif_matloc,

      ls_matlocx TYPE /sapapo/cif_matlocx,

      ls_matkey TYPE /sapapo/cif_matkey,

      ls_penalty1 TYPE /sapapo/cif_penalty1,

      ls_marm TYPE /sapapo/cif_marm,

      lv_tzone TYPE tzonref-tzone,

      lv_matnr TYPE /SAPAPO/CIF_MATLOC-ext_matnr,

      lv_no_pds TYPE bapi10014genfields-no_of_pds,

      lv_matid TYPE /sapapo/matkey-matid,

      lr_prod TYPE TABLE OF bapiproductrange,

      ls_prod TYPE bapiproductrange,

      lr_loc TYPE TABLE OF bapilocrange,

      ls_loc TYPE bapilocrange,

      lt_plan TYPE TABLE OF bapiversrange,

      lt_usage TYPE TABLE OF bapi10014pdsusage,

      lt_pds_head TYPE TABLE OF bapi10014pdsheado,

      lt_pds_component TYPE TABLE OF bapi10014pdscompo,

      lt_pds_component_final TYPE TABLE OF bapi10014pdscompo,

      lt_pds_activity TYPE TABLE OF bapi10014pdsacto,

      lt_pds_mode TYPE TABLE OF bapi10014pdsmodeo,

      lt_pds_mode_final TYPE TABLE OF bapi10014pdsmodeo,

      lt_pds_capacity_requirement TYPE TABLE OF bapi10014pdscapreqo,

      lt_pds_capacity_requirement_f TYPE TABLE OF bapi10014pdscapreqo,

      lt_pds_activity_final TYPE TABLE OF bapi10014pdsacto,

      ls_pds_head TYPE bapi10014pdsheado,

      ls_plan TYPE bapiversrange,

      ls_usage TYPE bapi10014pdsusage,

      ls_pds_component_final TYPE bapi10014pdscompo,

      ls_pds_component TYPE bapi10014pdscompo,

      ls_pds_capacity_requirement TYPE bapi10014pdscapreqo,

      ls_pds_mode TYPE bapi10014pdsmodeo,

      ls_pds_activity TYPE bapi10014pdsacto.

      **************************************************************************

      *Create the range for BAPI for product and locations

      LOOP AT it_matloc INTO ls_matloc.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

      input = ls_matloc-ext_matnr

      IMPORTING

      OUTPUT = lv_matnr

      .

      • ls_prod holds the products

      MOVE : 'I' TO ls_prod-sign,

      'EQ' TO ls_prod-option,

      lv_matnr TO ls_prod-low,

      lv_matnr TO ls_prod-high.

      APPEND ls_prod TO lr_prod.

      CLEAR ls_prod.

      • ls_loc holds the location

      MOVE : 'I' TO ls_loc-sign,

      'EQ' TO ls_loc-option,

      ls_matloc-ext_locno TO ls_loc-low,

      ls_matloc-ext_locno TO ls_loc-high.

      APPEND ls_loc TO lr_loc.

      CLEAR ls_loc.

      ENDLOOP.

      MOVE : 'I' TO ls_plan-sign,

      'EQ' TO ls_plan-option,

      '000' TO ls_plan-low.

      APPEND ls_plan TO lt_plan.

      CLEAR ls_plan.

      MOVE :'S' TO ls_usage-pds_usage.

      APPEND ls_usage TO lt_usage.

      CLEAR ls_usage.

      • Process all finished product material types

      • FERT - Finished goods

      • ZSUN - Sundries

      • HAWA - Trading goods

      LOOP AT it_matkey INTO ls_matkey WHERE att01 = 'FERT'

      OR att01 = 'ZSUN'

      OR att01 = 'HAWA'.

      CLEAR: lv_baserate, lv_rate, lv_baserate, lv_per, lv_actid,

      lv_resid, lv_ndpen_ord, lv_ndpen_fc, lv_ndpen_ordc,

      lv_ndpen_fcc.

      • use material specific default if one exists

      SELECT SINGLE bndpen_ord bndpen_fc

      FROM /sapapo/matmap AS a

      JOIN zndpenalty AS b ON amatnr = bmatnr

      INTO (lv_ndpen_ord, lv_ndpen_fc)

      WHERE a~ext_matnr = ls_matkey-ext_matnr.

      IF sy-subrc = 0.

      CLEAR: it_penalty1,ls_penalty1.

      ls_penalty1-method = 'M'.

      ls_penalty1-ext_matnr = ls_matkey-ext_matnr.

      ls_penalty1-demcl = 1.

      ls_penalty1-ndpen = lv_ndpen_ord.

      APPEND ls_penalty1 TO it_penalty1.

      ls_penalty1-demcl = 6.

      ls_penalty1-ndpen = lv_ndpen_fc.

      APPEND ls_penalty1 TO it_penalty1.

      CONTINUE. "get next material

      ENDIF.

      • get general default

      • SELECT SINGLE ndpen_ord ndpen_fc FROM zndpenalty

      • INTO (lv_ndpen_ord, lv_ndpen_fc)

      • WHERE matnr = ''.

      • IF sy-subrc <> 0.

      • CONTINUE.

      • ENDIF.

      • Use general defaults for sundaries

      IF ls_matkey-att01 = 'ZSUN'.

      CLEAR: ls_penalty1.

      ls_penalty1-method = 'M'.

      ls_penalty1-ext_matnr = ls_matkey-ext_matnr.

      ls_penalty1-demcl = 1.

      ls_penalty1-ndpen = lv_ndpen_ord.

      APPEND ls_penalty1 TO it_penalty1.

      ls_penalty1-demcl = 6.

      ls_penalty1-ndpen = lv_ndpen_fc.

      APPEND ls_penalty1 TO it_penalty1..

      CONTINUE. "get next material

      ENDIF.

      • for TRDUs/dollies pro-rata based on component qty & costs

      IF ls_matkey-meins = 'UN'.

      • find output qty on preferred SNP PPM

      CONVERT DATE sy-datum INTO TIME STAMP lv_today TIME ZONE lv_tzone.

      *Calling BAPI as converting PPM data structure to PDS

      CALL FUNCTION 'BAPI_PDSSRVAPS_GETLIST'

      EXPORTING

      logical_system = 'AP_300'

      IMPORTING

      number_of_pds = lv_no_pds

      TABLES

      product_selection = lr_prod

      location_selection = lr_loc

      planning_version_selection = lt_plan

      pds_usage = lt_usage

      pds_head = lt_pds_head

      pds_component = lt_pds_component

      pds_activity = lt_pds_activity

      pds_mode = lt_pds_mode

      pds_capacity_requirement = lt_pds_capacity_requirement.

      IF sy-subrc IS INITIAL.

      • Delete the PDS header table if Single-Level Costs (Variable) is NE '10'

      DELETE lt_pds_head WHERE single_level_costs_var NE 10.

      SORT lt_pds_head BY pds_name.

      SORT it_matloc BY ext_matnr.

      ******************************************************************

      *First step : Finding the output component (Type O)

      ******************************************************************

      • Access the variable material consumption of the output component product

      • lt_pds_component_final holds the output component product

      LOOP AT lt_pds_component INTO ls_pds_component.

      READ TABLE lt_pds_head INTO ls_pds_head

      WITH KEY pds_name = ls_pds_component-pds_name

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      IF ls_pds_component-component_indicator EQ 'O'. "Output Component

      READ TABLE it_matloc INTO ls_matloc

      WITH KEY ext_matnr = ls_pds_component-product

      BINARY SEARCH.

      IF sy-subrc IS INITIAL .

      APPEND ls_pds_component TO lt_pds_component_final.

      CLEAR ls_pds_component .

      ENDIF.

      ENDIF.

      ENDIF.

      ENDLOOP.

      • Map all other tables as per the header table so that entries in both are consisitent

      *{ If we eliminate entries from PDS_HEAD in step above, then the corresponding entries

      • tables PDS_ACTIVITY, PDS_MODE, PDS_CAPACITY_REQUIREMENT, PDS_COMPONENT should be removed

      • based on PDS_HEAD-PDS_NAME as common key } This is done as below ......

      LOOP AT lt_pds_activity INTO ls_pds_activity.

      READ TABLE lt_pds_head INTO ls_pds_head

      WITH KEY pds_name = ls_pds_activity-pds_name

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      APPEND ls_pds_activity TO lt_pds_activity_final.

      CLEAR ls_pds_activity.

      ENDIF.

      ENDLOOP.

      LOOP AT lt_pds_capacity_requirement INTO ls_pds_capacity_requirement.

      READ TABLE lt_pds_head INTO ls_pds_head

      WITH KEY pds_name = ls_pds_capacity_requirement-pds_name

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      APPEND ls_pds_capacity_requirement TO lt_pds_capacity_requirement_f.

      CLEAR ls_pds_capacity_requirement.

      ENDIF.

      ENDLOOP.

      LOOP AT lt_pds_mode INTO ls_pds_mode.

      READ TABLE lt_pds_head INTO ls_pds_head

      WITH KEY pds_name = ls_pds_mode-pds_name

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      APPEND ls_pds_mode TO lt_pds_mode_final.

      CLEAR ls_pds_mode.

      ENDIF.

      ENDLOOP.

      ******************************************************************

      *Second step : Finding the input component of Type I

      ******************************************************************

      *Filling up the penalty table with correct values

      LOOP AT lt_pds_component INTO ls_pds_component.

      *From the earlier BAPI results, PDS_COMPONENT table, select only records

      *where PDS_COMPONENT-ACTIVITY = the activity number from ACTIVITY table

      READ TABLE lt_pds_activity INTO ls_pds_activity

      WITH KEY pds_name = ls_pds_component-pds_name

      activity = ls_pds_component-activity

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      *Get the COMPONENT_INDICATOR = "I" (for Input components)

      *Obtain the variable material consumption

      IF ls_pds_component-component_indicator EQ 'I'.

      MOVE ls_pds_component-cons_var TO lv_qty.

      ENDIF.

      *To find if Product is of type FERT , use the PRODUCT field to look up in /SAPAPO/MATKEY

      *Get the MATID and proceed further to get ND Penalty cost from SNP04

      *

      clear lv_matnr .

      *To get the MATNR in the required format using the CONVERSION routine

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

      input = ls_pds_component-product

      IMPORTING

      OUTPUT = lv_matnr

      .

      SELECT SINGLE matid INTO lv_matid

      FROM /sapapo/matkey

      WHERE matnr EQ lv_matnr

      AND att01 EQ 'FERT'.

      IF sy-subrc IS INITIAL.

      SELECT SINGLE ndpen INTO lv_ndpen_ordc

      FROM /sapapo/snp04

      WHERE matid EQ lv_matid

      AND locid EQ space

      AND simid EQ space

      AND demcl EQ '1'. "Customer Demand

      IF NOT sy-subrc IS INITIAL.

      CLEAR lv_ndpen_ordc.

      ENDIF.

      SELECT SINGLE ndpen INTO lv_ndpen_fcc

      FROM /sapapo/snp04

      WHERE matid EQ lv_matid

      AND locid EQ space

      AND simid EQ space

      AND demcl EQ '6'. "Demand Forecast

      IF NOT sy-subrc IS INITIAL.

      CLEAR lv_ndpen_fcc.

      ENDIF.

      READ TABLE lt_pds_component_final INTO ls_pds_component

      WITH KEY pds_name = ls_pds_activity-pds_name

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      MOVE ls_pds_component_final-cons_var TO lv_per.

      ENDIF .

      CLEAR: ls_penalty1.

      ls_penalty1-method = 'M'.

      ls_penalty1-ext_matnr = ls_pds_component-product.

      ls_penalty1-demcl = 1.

      *To avoid the division by zero error use Initial check

      if not lv_per is initial.

      ls_penalty1-ndpen = lv_ndpen_ordc * lv_qty / lv_per.

      endif.

      APPEND ls_penalty1 TO it_penalty1.

      ls_penalty1-demcl = 6.

      *To avoid the division by zero error use Initial check

      if not lv_per is initial.

      ls_penalty1-ndpen = lv_ndpen_fcc * lv_qty / lv_per.

      endif.

      APPEND ls_penalty1 TO it_penalty1.

      ENDIF. "MATKEY select

      ENDIF. "READ lt_pds_activity

      ENDLOOP.

      **************************************************************************

      • Get Production rate for preferred source of supply

      • Get details for only particular product that matches

      LOOP AT lt_pds_head INTO ls_pds_head

      WHERE product = ls_matkey-ext_matnr.

      READ TABLE lt_pds_activity INTO ls_pds_activity

      WITH KEY pds_name = ls_pds_head-pds_name

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      READ TABLE lt_pds_mode INTO ls_pds_mode

      WITH KEY pds_name = ls_pds_activity-pds_name

      activity = ls_pds_activity-activity

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      READ TABLE lt_pds_capacity_requirement INTO ls_pds_capacity_requirement

      WITH KEY pds_name = ls_pds_head-pds_name

      activity = ls_pds_mode-activity

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      MOVE ls_pds_capacity_requirement-bucket_var_cons TO lv_rate.

      • get base rate for this production line

      SELECT SINGLE resuid

      INTO lv_resid

      FROM /sapapo/reskey

      WHERE name EQ ls_pds_capacity_requirement-resource

      AND logqs EQ 'ZBRITVIC'

      AND logsys EQ 'R3_100'.

      IF sy-subrc IS INITIAL.

      SELECT SINGLE c~baserate

      FROM /sapapo/res_head AS a

      JOIN /sapapo/loc AS b ON alocid = blocid

      JOIN zlinerate AS c ON blocno = clocno

      AND aname = cline

      INTO lv_baserate

      WHERE a~resuid = lv_resid.

      IF NOT sy-subrc IS INITIAL.

      CLEAR lv_baserate.

      ENDIF.

      ENDIF.

      ENDIF. " lt_PDS_CAPACITY_REQUIREMENT

      ENDIF. " lt_pds_mode

      READ TABLE lt_pds_component INTO ls_pds_component

      WITH KEY pds_name = ls_pds_activity-pds_name

      activity = ls_pds_activity-activity

      BINARY SEARCH.

      IF sy-subrc IS INITIAL.

      MOVE ls_pds_component-cons_var TO lv_per.

      ENDIF.

      *To avoid the division by zero error use Initial check

      if not lv_rate is initial.

      lv_rate = 3600 * lv_per / lv_rate.

      endif.

      SELECT SINGLE bndpen_ord bndpen_fc

      FROM /sapapo/matmap AS a

      JOIN zndpenalty AS b ON amatnr = bmatnr

      INTO (lv_ndpen_ord, lv_ndpen_fc)

      WHERE a~ext_matnr = ls_matkey-ext_matnr.

      IF NOT sy-subrc IS INITIAL.

      CLEAR :lv_ndpen_ord , lv_ndpen_fc.

      ENDIF.

      • insert entry for non-delivery costs for this material

      CLEAR: it_penalty1.

      ls_penalty1-method = 'M'.

      ls_penalty1-ext_matnr = ls_matkey-ext_matnr.

      ls_penalty1-demcl = 1.

      *To avoid the division by zero error use Initial check

      if not lv_rate is initial.

      ls_penalty1-ndpen = lv_ndpen_ord * lv_baserate / lv_rate.

      endif.

      APPEND ls_penalty1 TO it_penalty1.

      ls_penalty1-demcl = 6.

      *To avoid the division by zero error use Initial check

      if not lv_rate is initial.

      ls_penalty1-ndpen = lv_ndpen_fc * lv_baserate / lv_rate..

      endif.

      APPEND ls_penalty1 TO it_penalty1.

      ENDIF. " lt_pds_acitivity

      ENDLOOP.

      ENDIF. "BAPI

      ENDIF. "Unit for MEINS = 'UN'.

      ENDLOOP.

      ENDMETHOD.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.