We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

Re: [sap-abap] Runtime Error - Type Conflict When Calling a Function Module (Field Length)

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from lubos.adamka on Feb 6 at 4:16 AM
And for what reason you do not use standard structures from BAPI - I mean
standard data dictionary structures, but you created your types???

Lubos

---------------Original Message---------------
From: Aravind
Sent: Thursday, February 06, 2014 4:13 AM
Subject: Runtime Error - Type Conflict When Calling a Function Module (Field Length)

Hi,

I am getting a runtime error in the sales order creation program that while calling function module " BAPI_SALESDOCU_CREATEFROMDATA1" , the type it_header is correct but incorrect length it is saying for the SALES_HEADER_IN parameter.

My code is:
*&------------*
*& Report Z_SALES_BAPI_CR
*&
*&-----------*
*&
*&
*&-----------*

REPORT z_sales_bapi_cr.

PARAMETERS: p_auart TYPE auart OBLIGATORY.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.

TYPES: BEGIN OF ty_partner,
role TYPE bapipartnr-partn_role,
num TYPE bapipartnr-partn_numb,
END OF ty_partner.

TYPES: BEGIN OF ty_item,
itm_number TYPE bapisditem-itm_number,
material TYPE bapisditem-material,
plant TYPE bapisditem-plant,
target_qty TYPE bapisditem-target_qty,
END OF ty_item.

TYPES: BEGIN OF ty_itemx,
updateflag TYPE bapisditemx-updateflag,
itm_number TYPE bapisditemx-itm_number,
material TYPE bapisditemx-material,
plant TYPE bapisditemx-plant,
target_qty TYPE bapisditemx-target_qty,
END OF ty_itemx.

TYPES: BEGIN OF ty_header,
doc_type TYPE bapisdhead1-doc_type,
sales_org TYPE bapisdhead1-sales_org,
distr_chan TYPE bapisdhead1-distr_chan,
division TYPE bapisdhead1-division,
END OF ty_header.

TYPES: BEGIN OF ty_headerx,
doc_type TYPE bapisdhead1x-doc_type,
sales_org TYPE bapisdhead1x-sales_org,
distr_chan TYPE bapisdhead1x-distr_chan,
division TYPE bapisdhead1x-division,
updateflag TYPE bapisdhead1x-updateflag,
END OF ty_headerx.


TYPES: BEGIN OF ty_schedules_in,
sch_itm_number TYPE bapischdl-itm_number,
sch_sched_line TYPE bapischdl-sched_line,
sch_req_qty TYPE bapischdl-req_qty,
END OF ty_schedules_in.


TYPES: BEGIN OF ty_schedules_inx,
sch_itm_number TYPE bapischdlx-itm_number,
sch_sched_line TYPE bapischdlx-sched_line,
sch_updateflag TYPE bapischdlx-updateflag,
sch_req_qty TYPE bapischdlx-req_qty,
END OF ty_schedules_inx.


* Data declarations.
DATA: v_vbeln TYPE vbak-vbeln.

DATA: it_header TYPE STANDARD TABLE OF ty_header.
DATA: wa_header TYPE ty_header.

DATA: it_headerx TYPE STANDARD TABLE OF ty_headerx.
DATA: wa_headerx TYPE ty_headerx.

DATA: it_item TYPE STANDARD TABLE OF ty_item.
DATA: wa_item TYPE ty_item.
DATA: it_itemx TYPE STANDARD TABLE OF ty_itemx.
DATA: wa_itemx TYPE ty_itemx.

DATA: partner TYPE STANDARD TABLE OF ty_partner.
DATA: wa_partner TYPE ty_partner.
DATA: return TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: it_schedules_in TYPE STANDARD TABLE OF ty_schedules_in.
DATA: wa_schedules_in TYPE ty_schedules_in.
DATA: it_schedules_inx TYPE STANDARD TABLE OF ty_schedules_inx.
DATA: wa_schedules_inx TYPE ty_schedules_inx.

* Start-of-selection.
START-OF-SELECTION.

* Header data

* Sales document type
wa_header-doc_type = p_auart.
wa_headerx-doc_type = 'X'.

* Sales organization
wa_header-sales_org = p_vkorg.
wa_headerx-sales_org = 'X'.

* Distribution channel
wa_header-distr_chan = p_vtweg.
wa_headerx-distr_chan = 'X'.

* Division
wa_header-division = p_spart.
wa_headerx-division = 'X'.

wa_headerx-updateflag = 'I'.

APPEND wa_header to it_header.
APPEND wa_headerx to it_headerx.

* Partner data
* Sold to
wa_partner-role = 'AG'.
wa_partner-num = p_sold.
APPEND wa_partner TO partner.

* Ship to
wa_partner-role = 'WE'.
wa_partner-num = p_ship.
APPEND wa_partner TO partner.

* ITEM DATA
wa_itemx-updateflag = 'I'.

* Line item number.
wa_item-itm_number = '000010'.
wa_itemx-itm_number = 'X'.

* Material
wa_item-material = p_matnr.
wa_itemx-material = 'X'.

* Plant
wa_item-plant = p_plant.
wa_itemx-plant = 'X'.

* Quantity
wa_item-target_qty = p_menge.
wa_itemx-target_qty = 'X'.

APPEND wa_item TO it_item.
APPEND wa_itemx TO it_itemx.

* Fill schedule lines
wa_schedules_in-sch_itm_number = '000010'.
wa_schedules_in-sch_sched_line = '0001'.
wa_schedules_in-sch_req_qty = p_menge.
APPEND wa_schedules_in to it_schedules_in.

* Fill schedule line flags
wa_schedules_inx-sch_itm_number = '000010'.
wa_schedules_inx-sch_sched_line = '0001'.
wa_schedules_inx-sch_updateflag = 'X'.
wa_schedules_inx-sch_req_qty = 'X'.
APPEND wa_schedules_inx to it_schedules_inx.

* Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = it_header
sales_header_inx = it_headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = it_item
sales_items_inx = it_itemx
sales_schedules_in = it_schedules_in
sales_schedules_inx = it_schedules_inx
sales_partners = partner.

* Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'Error in creating document'.

ELSE.

* Commit the work.
COMMIT WORK AND WAIT.

WRITE: / 'Document ', v_vbeln, ' created'.

ENDIF.



Can anyone tell how to correct this error?

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2014 Ziff Davis, Inc. and message author.
Ziff Davis, Inc. 28 E 28th Street New York, NY 10016
lubos.adamka  

Programmer/Developer - Software
achievements
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Have a technical question? Need to find IT solutions? Ask your peers in the Toolbox for IT community.

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language