Skip to Content
0
Former Member
Jul 20, 2007 at 05:30 AM

call_invalid error

86 Views

Hi experts

this is my code, it's working pakka.

but for few inputs it gives the following error, what could be the reason.

Exception condition "CALL_INVALID" raised.

RAISE_EXCEPTION

Thanks in advance.

Regards

Rajaram

report test

TABLES : vbep,VBAP,stpo,mara,stpox,STKO,MAST.

TYPE-POOLS : slis.

  • Data Declarations

DATA : fcat TYPE slis_t_fieldcat_alv,

it_sort TYPE SLIS_T_SORTINFO_ALV ,

wa_sort type slis_sortinfo_alv,

ls_fcat LIKE LINE OF fcat,

fheader TYPE TABLE OF slis_listheader WITH NON-UNIQUE DEFAULT KEY

WITH HEADER LINE INITIAL SIZE 0.

DATA :i_repid LIKE sy-repid,

gs_layout TYPE slis_layout_alv,

week type n.

DATA: l_index TYPE sy-tabix.

*Internal Tables

DATA : BEGIN OF itab OCCURS 0,

VBELN like vbap-VBELN, "SALE ORDER

posnr LIKE vbap-POSNR, "LINE ITEM

STLNR1 like vbap-STLNR,

STLNR like STPO-STLNR,

MATNR LIKE VBAP-MATNR,

ARKTX LIKE VBAP-ARKTX,

MEINS LIKE VBAP-MEINS,

IDNRK LIKE STPO-IDNRK,

werks like vbap-werks,

MAKTX LIKE MAKT-MAKTX,

KWMENG LIKE VBAP-KWMENG,

MENG LIKE VBAP-ABLFZ,

STLAL LIKE MAST-STLAL,

STLAN LIKE MAST-STLAN,

CAPID LIKE TC04-CAPID,

UMVKZ LIKE VBAP-UMVKZ,

VRKME LIKE VBAP-VRKME,

END OF itab.

DATA: wa LIKE LINE OF itab.

DATA : BEGIN OF it_final OCCURS 0,

VBELN like vbap-VBELN, "SALE ORDER

posnr LIKE vbap-POSNR, "LINE ITEM

STLNR1 like vbap-STLNR,"BOM

STLNR like STPO-STLNR, "BOM no

MATNR LIKE VBAP-MATNR, "MATERIAL

ARKTX LIKE VBAP-ARKTX, "DESC

MEINS LIKE VBAP-MEINS, "BUn

IDNRK LIKE STPO-IDNRK, "COMPONENT

werks like vbap-werks, "PLANT

MAKTX LIKE MAKT-MAKTX, "DESC

MNGKO LIKE STPO-MENGE, "CONSUMPTION

ROANZ LIKE STPO-ROANZ, "BASE QTY

MEINS1 LIKE STPO-MEINS, " Un

KWMENG LIKE VBAP-KWMENG, "ORDER QTY

STLAL LIKE MAST-STLAL,

STLAN LIKE MAST-STLAN,

CAPID LIKE TC04-CAPID,

END OF it_final.

data : ibom1 like stpox occurs 0 with header line,

ibom2 like stpox occurs 0 with header line.

  • Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: zso FOR vbep-vbeln OBLIGATORY.

SELECT-OPTIONS: zli FOR vbep-posnr.

SELECT-OPTIONS: ZPL FOR VBAP-WERKS.

PARAMETERS ZQTY TYPE STKO-BMENG.

SELECTION-SCREEN END OF BLOCK bk1.

gs_layout-colwidth_optimize = 'X'.

  • Select query to read all the materials from sales order

select A~VBELN

A~POSNR

A~MATNR

A~ARKTX

A~STLNR

A~WERKS

A~KWMENG

A~MEINS

A~UMVKZ

A~VRKME

B~MATNR

B~STLAL

B~STLAN

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM VBAP AS A

INNER JOIN MAST AS B ON A~MATNR = B~MATNR

WHERE A~VBELN IN ZSO

AND A~POSNR IN ZLI

AND A~WERKS IN ZPL.

loop at itab.

if itab-VRKME = 'PAC' or itab-VRKME = 'PAK'.

itab-kwmeng = itab-kwmeng * itab-UMVKZ.

modify itab.

endif.

endloop.

  • Select all the alternative BOM against the material

sort itab by matnr.

  • Assigning the order quantity if required qunatity zero

loop at itab.

if zqty is initial.

itab-meng = itab-KWMENG.

modify itab.

endif.

ENDLOOP.

  • Assigning required quantity as the base quantity

loop at itab.

if zqty is initial.

exit.

else.

move zqty to itab-meng.

modify itab.

endif.

if itab-MATNR = ' '.

delete itab.

endif.

endloop.

  • Assigning all the corresponding fields from itab to itab1.

loop at itab.

IF ITAB-STLAN = '1'.

ITAB-CAPID = 'PP01'.

ELSEIF ITAB-STLAN = '5'.

ITAB-CAPID = 'SD01'.

ELSEIF ITAB-STLAN = '6'.

ITAB-CAPID = 'PC01'.

ELSEIF ITAB-STLAN = '4'.

ITAB-CAPID = 'INST'.

ELSEIF ITAB-STLAN = '2'.

ITAB-CAPID = 'ENGG'.

ELSEif itab-stlan <> 1

or itab-stlan <> 2

or itab-stlan <> 5

or itab-stlan <> 6

or ITAB-STLAN <> 4.

itab-capid = ' '.

ENDIF.

if zqty is initial.

itab-MENG = itab-meng.

else.

itab-meng = itab-meng.

itab-kwmeng = zqty.

endif.

if zqty is initial.

itab-KWMENG = itab-KWMENG.

ELSE.

itab-STLAL = itab-STLAL.

endif.

modify itab.

clear : itab.

endloop.

  • Calling the function module for collecting the bom components

loop at itab.

clear : ibom1[].

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

EXPORTING

capid = ITAB-CAPID

datuv = sy-datum

emeng = ITAB-meng

mehrs = 'X'

mtnrv = ITAB-matnr

stlal = ITAB-stlal

werks = ITAB-werks

TABLES

stb = IBOM1

EXCEPTIONS

alt_not_found = 1

call_invalid = 2

material_not_found = 3

missing_authorization = 4

no_bom_found = 5

no_plant_data = 6

no_suitable_bom_found = 7

conversion_error = 8

OTHERS = 9.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Moving all the fields to IT_FINAL.

LOOP AT IBOM1.

MOVE-CORRESPONDING ITAB TO IT_FINAL.

MOVE IBOM1-IDNRK TO IT_FINAL-IDNRK.

MOVE IBOM1-OJTXP TO IT_FINAL-MAKTX.

IF IT_FINAL-KWMENG LE 0.

MOVE 0 TO IT_FINAL-MNGKO.

ELSE.

MOVE IBOM1-MNGKO TO IT_FINAL-MNGKO.

ENDIF.

MOVE IBOM1-MEINS TO IT_FINAL-MEINS1.

APPEND IT_FINAL.

ENDLOOP.

ENDLOOP.

  • Calling the fieldcatelog

PERFORM EDIT_MASK.

i_repid = sy-repid.

PERFORM fieldcat.

wa_sort-fieldname = 'VBELN'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'POSNR'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'MATNR'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'ARKTX'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'KWMENG'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'STLAL'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'CAPID'.

wa_sort-tabname = 'IT_FINAL'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

  • Calling ALV GRID

*SORT IT_FINAL ASCENDING BY VBELN POSNR MATNR.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = i_repid

is_layout = gs_layout

it_fieldcat = fcat

IT_SORT = it_sort

i_save = 'A'

TABLES

t_outtab = it_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

&----


*& Form fieldcat

&----


  • text

----


FORM fieldcat.

MOVE sy-repid TO i_repid.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'VBELN'.

ls_fcat-outputlen = 10.

ls_fcat-seltext_m = 'Sales order'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'POSNR'.

ls_fcat-outputlen = 2.

ls_fcat-seltext_m = 'Item'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'MATNR'.

ls_fcat-outputlen = 20.

ls_fcat-seltext_m = 'Material'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'ARKTX'.

ls_fcat-outputlen = 30.

ls_fcat-seltext_m = 'Description'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'MEINS'.

ls_fcat-outputlen = 30.

ls_fcat-seltext_m = 'BUn'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-outputlen = 5.

ls_fcat-fieldname = 'KWMENG'.

IF ZQTY IS INITIAL.

ls_fcat-seltext_m = 'Order Qty'.

ELSE.

ls_fcat-seltext_m = 'Required Qty'.

endif.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'STLAL'.

ls_fcat-outputlen = 3.

ls_fcat-seltext_l = 'Alternative BOM'.

ls_fcat-seltext_m = 'Alt.BOM'.

ls_fcat-seltext_s = 'A.BOM'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'CAPID'.

ls_fcat-outputlen = 3.

ls_fcat-seltext_l = 'BOM Application'.

ls_fcat-seltext_m = 'BOM Appl.'.

ls_fcat-seltext_s = 'BOM Ap.'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'IDNRK'.

ls_fcat-outputlen = 15.

ls_fcat-seltext_l = 'Component'.

ls_fcat-seltext_m = 'Component'.

ls_fcat-seltext_s = 'Component'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'MAKTX'.

ls_fcat-outputlen = 15.

ls_fcat-seltext_l = 'Description'.

ls_fcat-seltext_m = 'Description'.

ls_fcat-seltext_s = 'Description'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'MNGKO'.

ls_fcat-outputlen = 5.

ls_fcat-seltext_l = 'Comp.Qty'.

ls_fcat-seltext_s = 'Comp.Qty'.

ls_fcat-seltext_m = 'Comp.Qty'.

APPEND ls_fcat TO fcat.

ls_fcat-tabname = 'IT_FINAL'.

ls_fcat-fieldname = 'MEINS1'.

ls_fcat-outputlen = 2.

ls_fcat-seltext_l = 'Un'.

ls_fcat-seltext_s = 'Un'.

ls_fcat-seltext_m = 'Un'.

APPEND ls_fcat TO fcat.

endform. "fieldcat

&----


*& Form EDIT_MASK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM EDIT_MASK .

loop at it_final.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

INPUT = it_final-vbeln

IMPORTING

OUTPUT = it_final-vbeln.

modify it_final.

endloop.

ENDFORM. " EDIT_MASK