cancel
Showing results for 
Search instead for 
Did you mean: 

Fill Batch number by referring a ODS

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member181964
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Surender,

I tried using that code, I am not getting any records loaded into the cube.

However, I see second record in the results via update rule debug. But it didn't append into the cube though.

I tried using '000' and both records updated with '000' in the cube.

Read table t_batch with key material = COMM_STRUCTURE-material

plant = COMM_STRUCTURE-plant

stor_loc = COMM_STRUCTURE-stor_loc.

If sy-subrc = 0.

RESULT = t_batch-batch.

else.

RESULT = '000'.

endif.

Thanks

Priya

Edited by: Priya Surya on Dec 9, 2010 10:25 PM

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks,

I did modify my code like 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.

and char routine has

RESULT = COMM_STRUCTURE-batch.

For above combination there two batch numbers, but I am only getting one value.

Mat Plant Stro_loc batch

abc 100 200 111

abc 100 200 112

But it is updating first records, not getting second record.

Can you help?

Thanks

Priya

..

Former Member
0 Kudos

In that case, you need to enhance your 2lis_03_bx,bf,um extractors with CHARG field.

Batch is associated with respective material document and you are now loosing this information. It cannot be reconstructed from master data.

Suppose you have one record in DATA_PACKAGE and you need to assign two batches - that means you need create 2 records from one. And there goes question how to distribute values beetween batches -> You need to load it for each material document item.

BR

Ondrej

Former Member
0 Kudos

Thanks Ondrej,

Any help with the code?

Priya

Former Member
0 Kudos

Hi Priya,

Based on your select single statement,your first record itself is satisfying the conditions. So it will not go to the second record.You may need to add some more condition to differentiate the records for batch.

Thanks.

Former Member
0 Kudos

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.