Skip to Content
author's profile photo Former Member
Former Member

Fill Batch number by referring a ODS

Hello Friends,

I have Batch number information in the ODS and I need to fill batch number in my Inventory cube by referring this ODS.

I wrote some code, but seems not working properly

*This code is in my Start routine*

DATA: BEGIN OF t_batch OCCURS 0,

material LIKE /BIC/AZIC_O0600-material,

plant LIKE /BIC/AZIC_O0600-plant,

stor_loc LIKE /BIC/AZIC_O0600-stor_loc,

batch LIKE /BIC/AZIC_O0600-batch.

DATA: END OF t_batch.

LOOP at DATA_PACKAGE.

SELECT single MATERIAL PLANT STOR_LOC BATCH

FROM /BIC/AZIC_O0600

INTO t_batch

WHERE material = DATA_PACKAGE-material

and plant = DATA_PACKAGE-PLANT

and stor_loc = DATA_PACKAGE-stor_loc.

ENDLOOP.

*This code is from my field routine.

*

LOOP AT t_batch.

IF t_batch-material = COMM_STRUCTURE-material AND

t_batch-plant = COMM_STRUCTURE-plant and

t_batch-stor_loc = COMM_STRUCTURE-stor_loc.

RESULT = t_batch-batch.

ENDIF.

ENDLOOP.

When I debug the code, I see batch number in t_batch table, but I donu2019t see any data updated in the cube.

Any ideas? Am I doing something wrong?

Thanks

Priya

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2009 at 03:14 PM

    Hello Priya,

    I would recommend you to enhance your infosource with 0BATCH, you won't need an internal table then. Furthermore you won't need char. routine either.

    LOOP would be as simple as this:

    LOOP at DATA_PACKAGE.

    SELECT single BATCH

    FROM /BIC/AZIC_O0600

    INTO DATA_PACKAGE-batch

    WHERE material = DATA_PACKAGE-material

    and plant = DATA_PACKAGE-PLANT

    and stor_loc = DATA_PACKAGE-stor_loc.

    if sy-subrc = 0.

    MODIFY DATA_PACKAGE.

    endif.

    ENDLOOP.

    You probably missing APPEND t_batch in your code.

    BR

    Ondrej

    Edited by: Ondrej Vach on Dec 16, 2009 4:17 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Priya,

      I think still you will get only one record for your Batch ,based on the conditions provided. Because Select Single /Read statement searches the records in your ODS based on the conditions and will return immediately with the first record once the condition is satiesfied. It will not go to the second record. If you want to update the second record,then you need to find some more additional conditions to get that record.

      Thanks.

  • Posted on Dec 18, 2009 at 09:17 AM

    Hi,

    Write the code like below.

    DATA: BEGIN OF t_batch OCCURS 0,
    	material LIKE /BIC/AZIC_O0600-material,
    	plant LIKE /BIC/AZIC_O0600-plant,
    	stor_loc LIKE /BIC/AZIC_O0600-stor_loc,
    	batch LIKE /BIC/AZIC_O0600-batch.
          END OF t_batch.
    
    
    "LOOP at DATA_PACKAGE. This is not required remove this line
    
    
    SELECT MATERIAL PLANT STOR_LOC BATCH FROM /BIC/AZIC_O0600 INTO t_batch for all entries in DATA_PACKAGE
    WHERE
     material = DATA_PACKAGE-material  and
     plant    = DATA_PACKAGE-PLANT     and
     stor_loc = DATA_PACKAGE-stor_loc.
    
     ABORT = 0.
    
    
    "ENDLOOP.  This is not required remove this line
    
    
    "This code is from my field routine.
    
    SORT t_batch by material batch stor_loc.
    
    Read table t_btach with key material = COMM_STRUCTURE-material
                                plant    = COMM_STRUCTURE-plant    
                                stor_loc = COMM_STRUCTURE-stor_loc.
    
    If sy-subrc = 0.
    
      RESULT = t_batch-PLANT.
    
    else.
      RESULT = ''.
    endif.
    
    ENDIF.
    
    ENDLOOP.

    Thanks

    Reddy

    Edited by: Surendra Reddy on Dec 18, 2009 10:17 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Try this. This should work. Check for any syntax .

      TYPES:BEGIN OF t_batch,
      	material LIKE /BIC/AZIC_O0600-material,
      	plant LIKE /BIC/AZIC_O0600-plant,
      	stor_loc LIKE /BIC/AZIC_O0600-stor_loc,
      	batch LIKE /BIC/AZIC_O0600-batch.
            END OF t_batch.
      
      data: lt_dp type table of DATA_PACKAGE_STRUCTURE,
            ls_dp type DATA_PACKAGE_STRUCTURE,
            lt_batch type table of t_batch,
            ls_batch type t_batch.
      
      lt_dp[] = data_package[].
      
      
      SELECT MATERIAL PLANT STOR_LOC BATCH 
      FROM /BIC/AZIC_O0600 
      INTO table lt_batch 
      for all entries in DATA_PACKAGE
      WHERE
       material = DATA_PACKAGE-material  and
       plant    = DATA_PACKAGE-PLANT     and
       stor_loc = DATA_PACKAGE-stor_loc.
      
      refresh data_package.
       
      loop at lt_dp into ls_dp .
        CLEAR LV_FLAG.
        loop at t_batch into ls_batch where 
                                  material = ls_dp-material
                                  plant    = ls_dp-plant    
                                  stor_loc = ls_dp-stor_loc.
        ls_dp-batch = wa_batch-batch.
        append wa_batch to data_package.
        lv_flag = 'X'.
        endloop.
      
        IF LV_FLAG IS INITIAL.
        append wa_batch to data_package.
        ENDIF.
      endloop.
      

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.