2014 May 08 12:01 PM
Hello guys.
ABAP it's not my strong skill, but i need to develop some report.
What i need:
input: material, SLED, plant
output: material, SLED, plant, values from characteristic field.
I have created sap query with additional field type c.
Below my code:
TYPES: BEGIN OF charast,
ATNAM(50) TYPE c,
ATWTB(8) TYPE n,
X(50) TYPE n,
C(50) TYPE n,
ATINN(50) TYPE n,
END OF charast.
DATA: char TYPE TABLE OF charast WITH HEADER LINE.
CALL FUNCTION 'VB_BATCH_GET_DETAIL'
EXPORTING
MATNR = MCH1-MATNR
CHARG = MCH1-CHARG
GET_CLASSIFICATION = 'X'
TABLES
CHAR_OF_BATCH = char.
LOOP AT char into TEST (This is an additional field type C.
ENDLOOP.
Questions:
1. How i can return internal table into standard abap type, because i can create additional field only with standart types.
2. Need i fetch exporting parameters before calling FM? Or sap query do it automatically, based on given values on selection screen of the report?
3. How i can return only needed field from FM output? Now, when i'm executing FM via SE37 it's show desired result, but when i'm getting it from code i see strange values.
4. If i don't know exactly return by an FM values, how i can fill structure dynamically?
5. How i can return result of a program not only to additional field but to layout?
Sorry for noob questions and thank you in advance guys!
2014 May 08 12:47 PM
Hi,
As per your requirement, you want to fetch batch characteristics data.
So first, find the batch[CHARG] as per Material and plant into one internal table, as it is needed to pass into FM.
Then do loop on that internal table and call FM "VB_BATCH_GET_DETAIL" inside the loop.
Now char in your FM is of type CLBATCH and you will get data into this table.
LOOP AT char into TEST (here TEST should be work area of type CLBATCH.
--assign the components of work area to your final table work area and append into it.
ENDLOOP.
at last use the final table for o/p.
you have declared char with header line so no need of work area[this is obsolete now, so better to declare work area]
Thanks,
Dharmishta
2014 May 09 7:11 AM
Hello.
Thank you for ur reply.
But can explain it as easy as possible because i'm not abaper...
Thank you!
2014 May 09 7:58 AM
Well, seems like it work fine for me.
Below my crappy, but working code:
DATA: material TYPE MCHB-MATNR,
batch TYPE MCHB-CHARG,
plant TYPE MCHB-WERKS,
sloc TYPE MCHB-LGORT,
gtdt TYPE STANDARD TABLE OF clbatch,
gtdit TYPE clbatch.
SELECT MATNR INTO material FROM MCHB
WHERE MATNR = MCHB-MATNR.
ENDSELECT.
SELECT CHARG INTO batch FROM MCHB
WHERE CHARG = MCHB-CHARG.
ENDSELECT.
SELECT WERKS INTO plant FROM MCHB
WHERE WERKS = MCHB-WERKS.
ENDSELECT.
SELECT LGORT INTO sloc FROM MCHB
WHERE LGORT = MCHB-LGORT.
ENDSELECT.
CALL FUNCTION 'VB_BATCH_GET_DETAIL'
EXPORTING
MATNR = material
CHARG = batch
WERKS = plant
GET_CLASSIFICATION = 'X'
TABLES
CHAR_OF_BATCH = gtdt.
READ TABLE gtdt INTO gtdit
WITH KEY atnam = 'BATCH_SHELF_LIFE_EXPIRY_DATE'.
GTD = gtdit-ATWTB.