BAPI_MATERIAL_GET_DETAIL cannot fetch MATERIALVALUATIONDATA

1.5k views Asked by At

When calling BAPI_MATERIAL_GET_DETAIL, I am able to fetch MATERIAL_GENERAL_DATA for a material from SAP server. But for the same material I am not able to fetch MATERIALVALUATIONDATA.

Here is my piece of code:

public static void step5WorkWithTable() throws JCoException{

    JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME1);        
    JCoFunction function = destination.getRepository().getFunction("BAPI_MATERIAL_GET_DETAIL");

    //function = destination.getRepository().getFunction("BAPI_COMPANYCODE_GETDETAIL");
    JCoParameterList listParams = function.getImportParameterList();
    listParams.setValue("MATERIAL", "DB004");
    //listParams.setValue("PLANT", "SN02");
    //listParams.setValue("VALUATIONTYPE", "7920");
    //listParams.setValue("VALUATIONAREA", "SN02");
    System.out.println(function);
    function.execute(destination);


    JCoParameterList resultParams = function.getExportParameterList();
    JCoStructure returnStructure = function.getExportParameterList().getStructure("RETURN");
    System.out.println(returnStructure);
    JCoStructure fieldList = resultParams.getStructure("MATERIALVALUATIONDATA");

    //JCoTable fieldList = function.getTableParameterList().getTable("MATERIALVALUATIONDATA");
    function.execute(destination);
    System.out.println(fieldList);
    Hashtable<String, String> returnHash = new Hashtable<String, String>();
    if(fieldList.getFieldCount() > 0){
        for(JCoFieldIterator fI = fieldList.getFieldIterator();fI.hasNextField();){
            JCoField tabField = fI.nextField();
            returnHash.put(tabField.getName(), tabField.getString());
        }
    }
    System.out.println(returnHash);
}

I am getting this output:

|-|------------------------|------------------------|--------|-----|---|
| STRUCTURE 'BAPIMATDOBEW'
|-|------------------------|------------------------|--------|-----|---|
|P|MOVING_PR               |STD_PRICE               |PRICE_UN|CURRE|CUR|
|-|------------------------|------------------------|--------|-----|---|
|0|   1   2   3   4   5   6|   7   8   9   0   1   2|   3   4|56789|012|
|-|------------------------|------------------------|--------|-----|---|
| |00000000000000000000000C|00000000000000000000000C|00000C00|     |   |
|-|------------------------|------------------------|--------|-----|---|

{PRICE_UNIT=0, PRICE_CTRL=, CURRENCY_ISO=, STD_PRICE=0.0000, MOVING_PR=0.0000, CURRENCY=}

But if I use function MATERIAL_GENERAL_DATA I am getting the perfect general information of that material

JCoStructure fieldList = resultParams.getStructure("MATERIAL_GENERAL_DATA");

|----------------------------------------|------------------|----|-|--|---------|------------------|--------------|------------------|---|------------------|----|--|--|--|---|------------------|--|--------------------------------|----------------|----------------|---|----------------|---|----------------|----------------|----------------|---|----------------------------------------|----------|---|---|---|---|--------|------------|--------|------------|--|-|------------------------------------------------|
| STRUCTURE 'BAPIMATDOA'
|----------------------------------------|------------------|----|-|--|---------|------------------|--------------|------------------|---|------------------|----|--|--|--|---|------------------|--|--------------------------------|----------------|----------------|---|----------------|---|----------------|----------------|----------------|---|----------------------------------------|----------|---|---|---|---|--------|------------|--------|------------|--|-|------------------------------------------------|
|MATL_DESC                               |OLD_MAT_NO        |MATL|I|DI|MATL_GROU|PROD_HIER         |BASIC_MATL    |STD_DESCR         |LAB|PROD_MEMO         |PAGE|CO|ST|TE|BAS|EAN_UPC           |EA|SIZE_DIM                        |GROSS_WT        |NET_WEIGHT      |UNI|VOLUME          |VOL|LENGTH          |WIDTH           |HEIGHT          |UNI|MANU_MAT                                |MFR_NO    |BAS|UNI|VOL|UNI|CREATED_|CREATED_BY  |LAST_CHN|CHANGED_BY  |MA|E|BASIC_MATL_NEW                                  |
|----------------------------------------|------------------|----|-|--|---------|------------------|--------------|------------------|---|------------------|----|--|--|--|---|------------------|--|--------------------------------|----------------|----------------|---|----------------|---|----------------|----------------|----------------|---|----------------------------------------|----------|---|---|---|---|--------|------------|--------|------------|--|-|------------------------------------------------|       |0123456789012345678901234567890123456789|012345678901234567|8901|2|34|567890123|456789012345678901|23456789012345|678901234567890123|456|789012345678901234|5678|90|12|34|567|890123456789012345|67|89012345678901234567890123456789|   0   1   2   3|   4   5   6   7|890|   1   2   3   4|567|   8   9   0   1|   2   3   4   5|   6   7   8   9|012|3456789012345678901234567890123456789012|3456789012|345|678|901|234|56789012|345678901234|56789012|345678901234|56|7|890123456789012345678901234567890123456789012345|
 |----------------------------------------|------------------|----|-|--|---------|------------------|--------------|------------------|---|------------------|----|--|--|--|---|------------------|--|--------------------------------|----------------|----------------|---|----------------|---|----------------|----------------|----------------|---|----------------------------------------|----------|---|---|---|---|--------|------------|--------|------------|--|-|------------------------------------------------|
|TEST NEW                                |                  |FERT|M|  |         |                  |              |                  |   |                  |    |  |  |  |EA |                  |  |                                |0000000012000C00|0000000010000C00|KG |0000000013000C00|CCM|0000000000000C00|0000000000000C00|0000000000000C00|   |                                        |          |EA |KGM|CMQ|   |20141111|DEMO1       |00000000|            |  | |                                                |
|----------------------------------------|------------------|----|-|--|---------|------------------|--------------|------------------|---|------------------|----|--|--|--|---|------------------|--|--------------------------------|----------------|----------------|---|----------------|---|----------------|----------------|----------------|---|----------------------------------------|----------|---|---|---|---|--------|------------|--------|------------|--|-|------------------------------------------------|

{UNIT_DIM=, IND_SECTOR=M, CONTAINER=, CHANGED_BY=, TEMP_CONDS=, WIDTH=0.000, MANU_MAT=, CREATED_ON=2014-11-11, PAGEFORMAT=, EMPTIESBOM=, VOLUME=13.000, CREATED_BY=DEMO1, UNIT_OF_WT_ISO=KGM, PROD_MEMO=, MATL_DESC=TEST NEW, STOR_CONDS=, LAST_CHNGE=0000-00-00, OLD_MAT_NO=, STD_DESCR=, PROD_HIER=, EAN_CAT=, BASIC_MATL=, BASE_UOM_ISO=EA, GROSS_WT=12.000, HEIGHT=0.000, UNIT_DIM_ISO=, UNIT_OF_WT=KG, MATL_TYPE=FERT, VOLUMEUNIT=CCM, VOLUMEUNIT_ISO=CMQ, EAN_UPC=, SIZE_DIM=, LAB_DESIGN=, NET_WEIGHT=10.000, BASE_UOM=EA, MATL_CAT=, DIVISION=, BASIC_MATL_NEW=, MFR_NO=, LENGTH=0.000, MATL_GROUP=}

1

There are 1 answers

0
curiousguy On BEST ANSWER

To Fetch MATERIALVALUATIONDATA , you need PLANT and VALUATIONAREA input parameter also along with material .

Here is an ex

listParams.setValue("MATERIAL", "DB004");
listParams.setValue("PLANT", "ZRP3");
    //listParams.setValue("VALUATIONTYPE", "7920");
listParams.setValue("VALUATIONAREA", "ZRP3");

And now I am able to fetch MATERIALVALUATIONDATA data

|-|------------------------|------------------------|--------|-----|---|
| STRUCTURE 'BAPIMATDOBEW'
|-|------------------------|------------------------|--------|-----|---|
|P|MOVING_PR               |STD_PRICE               |PRICE_UN|CURRE|CUR|
|-|------------------------|------------------------|--------|-----|---|
|0|   1   2   3   4   5   6|   7   8   9   0   1   2|   3   4|56789|012|
|-|------------------------|------------------------|--------|-----|---|
|S|00000000000000000000000C|00000000000000000100000C|00001C00|INR  |INR|
|-|------------------------|------------------------|--------|-----|---|

{PRICE_UNIT=1, PRICE_CTRL=S, CURRENCY_ISO=INR, STD_PRICE=10.0000, MOVING_PR=0.0000, CURRENCY=INR}