Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Selecting from change pointer internal table...

hello everyone,

I have the following in my code:

data: begin of i_matl_details occurs 0,

matnr type mara-matnr, "Material Number

bstme type mara-bstme, "Purchase Order Unit of Measure

vpreh type mara-vpreh, "Comparison Price Unit

matkl type mara-matkl, "Material Group

meins type mara-meins, "Base Unit of Measure

mfrnr type mara-mfrnr, "Number of a Manufacturer

mfrpn type mara-mfrpn, "Manufacturer Part Number

maktx type makt-maktx, "Material Description (Short)

plifz type marc-plifz, "Planned Delivery Time in Days

po_text like tline-tdline, "Purchase Order Text int_notes like tline-tdline, "Internal Comment

end of i_matl_details.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

DATE_OF_CHANGE = p_b_date

OBJECTCLASS = 'MATERIAL'

TIME_OF_CHANGE = p_b_time

DATE_UNTIL = p_e_date

TIME_UNTIL = p_e_time

TABLES

I_CDHDR = i_pt_cdhdr

EXCEPTIONS

NO_POSITION_FOUND = 1

WRONG_ACCESS_TO_ARCHIVE = 2

TIME_ZONE_CONVERSION_ERROR = 3

OTHERS = 4.

select maramatnr marabstme maravpreh maramatkl marameins maramfrnr mara~mfrpn

maktmaktx marcplifz

from mara

join marc on marcmatnr = maramatnr

join makt on maktmatnr = maramatnr

and spras = sy-langu

into table i_matl_details

where mara~mtart in s_matl.

Currently, this code is selecting material details based on material type.

I am using the change pointer function module to read changes only so that only deltas are loaded. Therefore, the selection code above would be wrong because even though I am reading changes, I am not selecting from it. I need to select all changed material from internal table i_pt_cdhdr.

How can I use the 'for all entries' statement so that selection is based on material type and material is selected only from the change pointer internal table in the function module?

Thanks in advance.

Regards,

Fred.

Tags:
replied

Take a look at this.

TABLES: mara.

PARAMETERS: p_b_date LIKE sy-datum,
            p_b_time LIKE sy-uzeit,
            p_e_date LIKE sy-datum,
            p_e_time LIKE sy-uzeit.

SELECT-OPTIONS: s_matl FOR mara-matkl.

DATA: BEGIN OF i_matl_details OCCURS 0,
        matnr   TYPE mara-matnr, "Material Number
        bstme   TYPE mara-bstme, "Purchase Order Unit of Measure
        vpreh   TYPE mara-vpreh, "Comparison Price Unit
        matkl   TYPE mara-matkl, "Material Group
        meins   TYPE mara-meins, "Base Unit of Measure
        mfrnr   TYPE mara-mfrnr, "Number of a Manufacturer
        mfrpn   TYPE mara-mfrpn, "Manufacturer Part Number
        maktx   TYPE makt-maktx, "Material Description (Short)
        plifz   TYPE marc-plifz, "Planned Delivery Time in Days
        po_text LIKE tline-tdline, "Purchase Order Text int_notes like tline-tdline, "Internal Comment
END OF i_matl_details.

DATA: BEGIN OF i_updtd_materials OCCURS 0,
        matnr LIKE mara-matnr.
DATA: END OF i_updtd_materials.

DATA: BEGIN OF i_pt_cdhdr OCCURS 0.
        INCLUDE STRUCTURE  cdhdr.
DATA: END OF i_pt_cdhdr.

START-OF-SELECTION.

  CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
    EXPORTING
      date_of_change             = p_b_date
      objectclass                = 'MATERIAL'
      time_of_change             = p_b_time
      date_until                 = p_e_date
      time_until                 = p_e_time
    TABLES
      i_cdhdr                    = i_pt_cdhdr
    EXCEPTIONS
      no_position_found          = 1
      wrong_access_to_archive    = 2
      time_zone_conversion_error = 3
      OTHERS                     = 4.

  SORT i_pt_cdhdr BY objectid.

  DELETE ADJACENT DUPLICATES FROM i_pt_cdhdr COMPARING objectid.

  LOOP AT i_pt_cdhdr.
    MOVE i_pt_cdhdr-objectid TO i_updtd_materials-matnr.
    APPEND i_updtd_materials.
    CLEAR i_updtd_materials.
  ENDLOOP.

  SELECT mara~matnr mara~bstme mara~vpreh
         mara~matkl mara~meins mara~mfrnr
         mara~mfrpn makt~maktx marc~plifz
    FROM mara INNER JOIN marc ON marc~matnr = mara~matnr
              INNER JOIN makt ON makt~matnr = mara~matnr
    INTO TABLE i_matl_details FOR ALL ENTRIES IN i_updtd_materials
   WHERE mara~matnr EQ i_updtd_materials-matnr
     AND mara~mtart IN s_matl
     AND makt~spras EQ sy-langu.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question