Application Development and Automation 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: 
Read only

MV45AFZZ

Former Member
0 Likes
797

Hi Gurus,

Iam facing one problem when saving sales order through VA01, VA02.

Tha following code is working fine in one Sales organization.

But other sales organizations it is not working.

The problem is the filelds kdkg1(freight), kdkg2(insurance)

values are coming in import statement for one sales org but these values are not coming for other sales organizations.

Here iam attaching the code.

FORM userexit_save_document_prepare.

************************************************

DATA: l_kdkg1 LIKE vbkd-kdkg1,

l_kdkg2 LIKE vbkd-kdkg2,

**************************************************

l_auart LIKE vbak-auart,

l_vbeln LIKE vbak-vbeln,

l_ldval LIKE vbak-kvgr4,

l_warn.

CASE sy-tcode.

WHEN 'VA01' OR 'VA02'.

*****************************************************

IMPORT: l_kdkg1 FROM MEMORY ID 'ALS_MEM_01',

l_kdkg2 FROM MEMORY ID 'ALS_MEM_02',

l_warn FROM MEMORY ID 'ALS_MEM_03',

*****************************************************

l_ldval FROM MEMORY ID 'YFIELD_KVGR4'.

IF NOT l_ldval IS INITIAL.

IF l_ldval NE 'L01'.

MESSAGE i019(yd).

"Maintain LD Rate for this Sales Order using transaction code VK11

ENDIF.

ENDIF.

  • FREE: MEMORY ID 'ALS_MEM_01',

  • MEMORY ID 'ALS_MEM_02',

  • MEMORY ID 'ALS_MEM_03'.

  • GET PARAMETER ID 'AAT' FIELD L_AUART.

IF sy-tcode EQ 'VA01'.

l_auart = xvbak-auart.

EXPORT l_auart TO MEMORY ID 'YFIELD_AUART'.

ELSE.

GET PARAMETER ID 'AUN' FIELD l_vbeln.

SELECT SINGLE auart INTO l_auart FROM vbak WHERE vbeln EQ l_vbeln.

ENDIF.

  • IF SY-SUBRC EQ 0.

CASE l_auart.

*

  • WHEN 'ZORD' OR 'ZOEX' OR 'ZODE' OR 'ZORF' OR 'ZOEC' OR 'ZFAB'

  • OR 'ZOET'." OR 'ZOES'.

                                          • START-OF-CHANGES *****************************

WHEN 'ZORD' OR 'ZOEX' OR 'ZODE' OR 'ZORF' OR 'ZOEC' OR 'ZFAB'

OR 'ZOET' OR 'ZOES' OR 'ZVRD' OR 'ZVEX' OR 'ZVDE'

OR 'ZBRD' OR 'ZBEX' OR 'ZBDE'.

                                          • END-OF-CHANGES ******************************

IF l_warn NE 'X'.

CASE l_kdkg1.

WHEN 'F1'.

CASE l_kdkg2.

WHEN 'T1'.

READ TABLE xkomv WITH KEY kschl = 'ZHD0'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i007(ys). "Please maintain value for condition ZHD0.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

WHEN 'T2'.

READ TABLE xkomv WITH KEY kschl = 'ZHD0'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i007(ys). "Please maintain value for condition ZHD0.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

READ TABLE xkomv WITH KEY kschl = 'ZINS'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i008(ys). "Please maintain value for condition ZINS.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

ENDCASE.

WHEN 'F2'.

CASE l_kdkg2.

WHEN 'T1'.

WHEN 'T2'.

READ TABLE xkomv WITH KEY kschl = 'ZINS'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i008(ys). "Please maintain value for condition ZINS.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

ENDCASE.

ENDCASE.

ENDIF.

ENDCASE.

  • ENDIF.

  • ENDCASE.

ENDCASE.

Your help will be highly appreciated

Thanks in advance

Rahul

Hi Gurus,

Iam facing one problem when saving sales order through VA01, VA02.

Tha following code is working fine in one Sales organization.

But other sales organizations it is not working.

The problem is the filelds kdkg1(freight), kdkg2(insurance)

values are coming in import statement for one sales org but these values are not coming for other sales organizations.

Here iam attaching the code.

FORM userexit_save_document_prepare.

************************************************

DATA: l_kdkg1 LIKE vbkd-kdkg1,

l_kdkg2 LIKE vbkd-kdkg2,

**************************************************

l_auart LIKE vbak-auart,

l_vbeln LIKE vbak-vbeln,

l_ldval LIKE vbak-kvgr4,

l_warn.

CASE sy-tcode.

WHEN 'VA01' OR 'VA02'.

*****************************************************

IMPORT: l_kdkg1 FROM MEMORY ID 'ALS_MEM_01',

l_kdkg2 FROM MEMORY ID 'ALS_MEM_02',

l_warn FROM MEMORY ID 'ALS_MEM_03',

*****************************************************

l_ldval FROM MEMORY ID 'YFIELD_KVGR4'.

IF NOT l_ldval IS INITIAL.

IF l_ldval NE 'L01'.

MESSAGE i019(yd).

"Maintain LD Rate for this Sales Order using transaction code VK11

ENDIF.

ENDIF.

  • FREE: MEMORY ID 'ALS_MEM_01',

  • MEMORY ID 'ALS_MEM_02',

  • MEMORY ID 'ALS_MEM_03'.

  • GET PARAMETER ID 'AAT' FIELD L_AUART.

IF sy-tcode EQ 'VA01'.

l_auart = xvbak-auart.

EXPORT l_auart TO MEMORY ID 'YFIELD_AUART'.

ELSE.

GET PARAMETER ID 'AUN' FIELD l_vbeln.

SELECT SINGLE auart INTO l_auart FROM vbak WHERE vbeln EQ l_vbeln.

ENDIF.

  • IF SY-SUBRC EQ 0.

CASE l_auart.

*

  • WHEN 'ZORD' OR 'ZOEX' OR 'ZODE' OR 'ZORF' OR 'ZOEC' OR 'ZFAB'

  • OR 'ZOET'." OR 'ZOES'.

                                          • START-OF-CHANGES *****************************

WHEN 'ZORD' OR 'ZOEX' OR 'ZODE' OR 'ZORF' OR 'ZOEC' OR 'ZFAB'

OR 'ZOET' OR 'ZOES' OR 'ZVRD' OR 'ZVEX' OR 'ZVDE'

OR 'ZBRD' OR 'ZBEX' OR 'ZBDE'.

                                          • END-OF-CHANGES ******************************

IF l_warn NE 'X'.

CASE l_kdkg1.

WHEN 'F1'.

CASE l_kdkg2.

WHEN 'T1'.

READ TABLE xkomv WITH KEY kschl = 'ZHD0'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i007(ys). "Please maintain value for condition ZHD0.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

WHEN 'T2'.

READ TABLE xkomv WITH KEY kschl = 'ZHD0'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i007(ys). "Please maintain value for condition ZHD0.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

READ TABLE xkomv WITH KEY kschl = 'ZINS'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i008(ys). "Please maintain value for condition ZINS.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

ENDCASE.

WHEN 'F2'.

CASE l_kdkg2.

WHEN 'T1'.

WHEN 'T2'.

READ TABLE xkomv WITH KEY kschl = 'ZINS'.

IF sy-subrc EQ 0.

IF xkomv-kbetr IS INITIAL.

MESSAGE i008(ys). "Please maintain value for condition ZINS.

l_warn = 'X'.

EXPORT l_warn TO MEMORY ID 'ALS_MEM_03'.

*

  • FREE MEMORY ID 'ALS_MEM_03'.

ENDIF.

ENDIF.

ENDCASE.

ENDCASE.

ENDIF.

ENDCASE.

  • ENDIF.

  • ENDCASE.

ENDCASE.

Your help will be highly appreciated

Thanks in advance

Rahul

1 REPLY 1
Read only

Former Member
0 Likes
574

Hi,

No one here can fix this since the problem is not in the code you provide. You do a memory Import only, but we have no idea where you have done the memory export. This is not in the code here, so I assume it is in a different include - probably within MV45AFZZ. Do a global search for the memory export, since this is where the problem is.

I really hate debugging and discovering a memory import like this without documentation. For that reason I recommend to ALWAYS document memory import/exports - e.g.

  • Exported in MV45AFZZ, form move_to_vbap.

As a different comment, I ( and SAP ) advise againt using SY-TCODE to distiguish between create and change mode. Use T180-TRTYP instead. Use T180-TRVOG = '0' to restrict to sales orders.