cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module - 2

Former Member
0 Kudos

Hello again,

I have not really solved the problem I had a couple of hours ago. Maybe someone can help me to understand why this program does not work.

REPORT Z_TEST_FUNKTIONSMODUL.

DATA: it_order TYPE STANDARD TABLE OF VPKVBAKTTYP.

DATA: wa_order TYPE VBAK.

wa_order-vbeln = '5100000'.

CALL FUNCTION '/SAPNEA/SMAPI_ORDER_GETDETAIL'

EXPORTING

PI_ORDER_HEADER = wa_order

  • PI_PARVW =

  • PI_PRICE_CONDITION1 = 'PR00'

  • PI_PRICE_CONDITION2 =

  • PI_PRICE_CONDITION3 =

  • PI_TAX_CONDITION =

  • PI_UNIT_SPLIT = 50

  • PI_TEXT_ID = '0001'

  • PI_LANGUAGE = SY-LANGU

  • IMPORTING

  • PO_ORDER_HEADER =

  • RETURN =

TABLES

POT_ORDER_ITEM = it_order.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Well,

If the code that u have posted is the code of the entire report, then if even if u execute it and if it is successfull u will never know.

First read the contens of parameter RETURN into a work area. See if it has message type 'E'. That means there has been an error.

You can simply write that error message using field RETURN-MESSAGE.

If not then the execution is successfull and u can read the contents of IT_ORDER by looping.

Loop at IT_ORDER.

Write : IT_ORDER.

Endloop.

First assign WA_RETURN TYPE BAPIRET2 to RETURN parameter of FM. then read it if it has message type 'E'.

i.e WA_RETURN-TYPE eq 'E'.

Then if it is error just display it or loop at the table and display its contents.

eddy_declercq
Active Contributor
0 Kudos

Hi,

Pls don't forget to reward points and close the question if you find the answers useful.

Eddy

Former Member
0 Kudos

IT_RETURN TYPE BAPIRET2.

CALL FUNCTION '/SAPNEA/SMAPI_ORDER_GETDETAIL'

EXPORTING

PI_ORDER_HEADER = wa_order

  • PI_PARVW =

  • PI_PRICE_CONDITION1 = 'PR00'

  • PI_PRICE_CONDITION2 =

  • PI_PRICE_CONDITION3 =

  • PI_TAX_CONDITION =

  • PI_UNIT_SPLIT = 50

  • PI_TEXT_ID = '0001'

  • PI_LANGUAGE = SY-LANGU

  • IMPORTING

  • PO_ORDER_HEADER =

RETURN = IT_RETURN

TABLES

POT_ORDER_ITEM = it_order.

Are u telling me that IT_RETURN is empty?

Please confirm.

If not, read the contents of structure IT_RETURN and let us know.

Former Member
0 Kudos

How do I know if it is empty? I mean when I f8, nothing is happening.

Former Member
0 Kudos

Hi,

THe return parameter will contain the error message if there is any problem with the FM execution.

Can u find out what is the error message, so that we can investiage further.

Former Member
0 Kudos

I do not get any message. Nothing is happening when I execute.

Former Member
0 Kudos

Sir,

You will have to let the program know what you want it to do. The piece of code will simply return the sales order ( if it exists ) item deatils in the internal table. Later if you want to show the details on screen you have to use write staement or you have to code for any other requirement. program by itself would not do anything.

Cheers.

Former Member
0 Kudos

Thanks for your answear.

Can I write something like this?

Data: wa_result LIKE LINE OF it_order.

LOOP AT it_order INTO wa_result.

WRITE: test-POSNR_VA

ENDLOOP.

Former Member
0 Kudos

You can go to transaction VA03 to look up your sales document number.

Sudha

Former Member
0 Kudos

Try this

DATA: it_order TYPE STANDARD TABLE OF /SAPNEA/MR3_ORDER_ITEM

.

DATA: wa_order TYPE /SAPNEA/MR3_ORDER_HEADER.

wa_order-salesdocument = '5100000'.

CALL FUNCTION '/SAPNEA/SMAPI_ORDER_GETDETAIL'

EXPORTING

PI_ORDER_HEADER = wa_order

  • PI_PARVW =

  • PI_PRICE_CONDITION1 = 'PR00'

  • PI_PRICE_CONDITION2 =

  • PI_PRICE_CONDITION3 =

  • PI_TAX_CONDITION =

  • PI_UNIT_SPLIT = 50

  • PI_TEXT_ID = '0001'

  • PI_LANGUAGE = SY-LANGU

  • IMPORTING

  • PO_ORDER_HEADER =

  • RETURN =

TABLES

POT_ORDER_ITEM = it_order.

if sy-subrc ne 0.

ENDIF.

Make sure sales order no 5100000 exists in your system.

Verify in VA03.

Cheers

Former Member
0 Kudos

if sy-subrc ne 0.

ENDIF.

What in word does that mean? I want a message for example "not an ordernumber" if 51.... does not exist.

Vinod_Chandran
Active Contributor
0 Kudos

Hi Linn,

Please change the program as follows and try.

DATA: it_order TYPE STANDARD TABLE OF /SAPNEA/MR3_ORDER_ITEM.

DATA: wa_order TYPE /SAPNEA/MR3_ORDER_HEADER.

wa_order-SALESDOCUMENT = '0005100000'.

Cheers

Vinod

Message was edited by: Vinod C

eddy_declercq
Active Contributor
0 Kudos

Hi,

What does the FM when you execute it via se37?

Why don't you use the types defined in the FM?

PI_ORDER_HEADER -> /SAPNEA/MR3_ORDER_HEADER

POT_ORDER_ITEM -> /SAPNEA/MR3_ORDER_ITEM

Eddy

Former Member
0 Kudos

Just one question. I think that 0005100000 is wrong. Where exactly in SAP can I look up a salesdocumentnumber?

Former Member
0 Kudos

Hi Linn,

Go n see the VBAK table. In my system the code is working.

Reg,

Arpit

Former Member
0 Kudos

Not it mine. When I execute nothing is happening.