Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Insert code in prgram to check sales order exits in your own program

Former Member
0 Kudos

Hi Experts

I want to insert a coding in IDOC , can anyone write in abap coding and show .....The program is to check if sales order for category PSTYV ( CATEGORY ) for items ...

if found set flag true else set flag false...

Eg

clear flag

  • insert code

to check s/o for ZTAC item found

if found

set flag = true

else

set flag = false

So how can I write a a code in ABAP

Thanks in advanced

Piroz

1 ACCEPTED SOLUTION

franois_henrotte
Active Contributor
0 Kudos

check table for category is TVPT so you should just SELECT in this table and if SY-SUBRC = 0 then the category exists...

2 REPLIES 2

franois_henrotte
Active Contributor
0 Kudos

check table for category is TVPT so you should just SELECT in this table and if SY-SUBRC = 0 then the category exists...

Former Member
0 Kudos

Hi Fracis

Thanks for your advice I did in this way , Is there any correction required

form look_sap_saleord using p_in_string

p_material_in " Material No exits

p_site_in " plant

changing p_out_saleord_e " sales order

p_out_material_e " Mat No

p_out_order_e " Prod Order

p_out_wemng_e " QTY goods received for order item

p_out_psmng_e. " Ordered Qty Item

data: lva_prodord like afpo-aufnr, " Production Order

lva_prodmat like afpo-matnr, " Material Number

lva_saleord like vbkd-vbeln, " Sales Order

lva_pstyv like vbap-pstyv, " Category

lva_wemng like afpo-wemng, " Quantity of goods received for the order item

lva_psmng like afpo-psmng, " Ordered Qty Item

lva_count type i. " counter validation

  • CHECK FOR SALES ORDER IN VBAP IF EXITS

  • GO TO DELIVERES

  • ELSE CHECK REQUIRED PRODUCTION ORDER

  • ihrez_e Ship to party

  • check single if the sales order exits

select vbeln from vbkd into vbkd-vbeln

where ihrez_e eq p_in_string.

  • Is the sales order exits for ZTAN Category ?

select vbeln from vbap into vbap-vbeln

where vbeln eq vbkd-vbeln and

werks eq p_site_in and

matnr eq p_material_in and

pstyv = 'ZTAN'.

  • The sales order is for the specified plant.

lva_saleord = vbap-vbeln.

lva_prodmat = vbap-matnr.

exit.

endselect.

  • when an order for this plant has been found.

if not lva_saleord is initial.

exit.

endif.

endselect.

check not lva_saleord is initial.

select count(*) into lva_count from vbap

where vbeln = lva_saleord.

if lva_count eq 1.

select vbeln matnr aufnr pstyv

into (lva_saleord, lva_prodmat, lva_prodord, lva_pstyv) from vbap

where vbeln = lva_saleord and

matnr = p_material_in and

pstyv = 'ZTAN'.

exit.

endselect.

else.

select vbeln matnr aufnr pstyv

into (lva_saleord, lva_prodmat, lva_prodord, lva_pstyv) from vbap

where vbeln = lva_saleord

and matnr = p_material_in.

exit.

endselect.

endif.

move: lva_saleord to p_out_saleord_e, " sales order

lva_prodord to p_out_order_e, " production order

lva_prodmat to p_out_material_e, " material no

lva_psmng to p_out_psmng_e, " QTY Ordered

lva_wemng to p_out_wemng_e. " Qty Received goods

  • lva_wemng to p_out_wemng_e. " Quantity of goods received for the order item

endform. " look_sap_sales ord

Regards