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

BAPI / FM for MEK2

former_member599326
Participant
0 Likes
4,077

Hi,

I have used BDC for MEK2 (Change condition record). It is working perfectly.

But now our requirement is to achieve the same through BAPI or FM.. Can you please suggest BAPI or FM for this ???

Regards,

Hi,

I have used BDC for MEK2 (Change condition record). It is working perfectly.

But now our requirement is to achieve the same through BAPI or FM.. Can you please suggest BAPI or FM for this ???

Regards,

12 REPLIES 12
Read only

Former Member
0 Likes
2,948

Hi Santhosh,

Please cehck this http://scn.sap.com/message/2550343#2550343

Thanks

Guruprasad G

Read only

0 Likes
2,948


Hi Santosh,

Please see the below code, It might be helpful for your requirement.


PARAMETERS: p_KBETR type KBETR DEFAULT '99'.

PARAMETERS: p_KNUMA type KNUMA_AG DEFAULT 'X000009996'.

PARAMETERS: p_datef type sy-datum DEFAULT '20130401'.

PARAMETERS: p_datet type sy-datum DEFAULT '20130731'.

PARAMETERS: p_kunnr TYPE kunnr DEFAULT '28523272'.

PARAMETERS: p_matnr type matnr DEFAULT 'P7734527'.

START-OF-SELECTION.



DATA:

cr
LIKE TABLE OF komv WITH HEADER LINE, " copy_records

nr
, "New_Record

key_fields
LIKE TABLE OF komg WITH HEADER LINE,

komk
LIKE TABLE OF komk WITH HEADER LINE,

komp
LIKE TABLE OF komp WITH HEADER LINE,

COPY_RECS_IDOC
LIKE TABLE OF KOMV_IDOC WITH HEADER LINE,

  i_kona
TYPE kona.





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

* KOMK/KOMP Fuellen

*Fill KOMK





komk
-mandt = '210'.

komk
-vkorg = '1310'.

komk
-vtweg = '01'.

komk
-spart = '01'.

komk
-kunnr = p_kunnr.

komk
-kappl = 'V'.

komk
-ERDAT = sy-datum.



komp
-kposn = '000001'.

komp
-matnr = p_matnr.

komp
-KNUMA_AG = p_KNUMA.

komp
-kposn = '000001'.



key_fields
-mandt  = '210'.

key_fields
-vkorg = '3376'.

key_fields
-kunnr = p_kunnr.

key_fields
-vtweg = '01'.

key_fields
-spart = '01'.

key_fields
-matnr p_matnr.



cr
-kappl = 'V'.

cr
-kschl = 'ZLPO'.

cr
-krech = 'C'.

cr
-KBETR = p_KBETR.

cr
-waers = 'GBP'.

cr
-kpein = 1.

cr
-kmein = 'CS'.

cr
-kopos = 01.

cr
-kzbzg = 'C'.

*cr-knumh = '0005014306'.

APPEND cr.



  i_kona
-abtyp = 'C'.

  i_kona
-knuma  p_knuma.



*COPY_RECS_IDOC-KNUMA_AG = p_KNUMA.

*append COPY_RECS_IDOC.



CALL FUNCTION 'RV_CONDITION_RESET'.



* --> KOMK/KOMP werden korrekt gefüllt. Funktion i.o.

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







CALL FUNCTION 'RV_CONDITION_COPY'

 
EXPORTING

    application             
= 'V'

    condition_table         
= '517'

    condition_type          
= 'ZLPO'

    date_from               
= p_datef

    date_to                 
= p_datet

    enqueue                 
= 'X'

    i_komk                  
= komk

    i_komp                  
= komp

    key_fields              
= key_fields

    maintain_mode           
= 'A'

      no_authority_check      
= space

      no_field_check          
= 'X'

      keep_old_records        
= space

      overlap_confirmed       
= 'X'

   i_kona                  
= i_kona

   SELECTION_DATE          
= sy-datum

 
IMPORTING

    e_komk                  
= komk

    e_komp                  
= komp

    new_record              
= nr

 
TABLES

    copy_records            
= cr

    COPY_RECS_IDOC          
= COPY_RECS_IDOC

 
EXCEPTIONS

    enqueue_on_record       
= 01

    invalid_application     
= 02

    invalid_condition_number
= 03

    invalid_condition_type  
= 04

    no_authority_ekorg      
= 05

    no_authority_kschl      
= 06

    no_authority_vkorg      
= 07

    no_selection            
= 08

    table_not_valid         
= 09.



CALL FUNCTION 'RV_CONDITION_SAVE'.

CALL FUNCTION 'RV_CONDITION_RESET'.



commit work.

Regards,

Prasenjit Mishra

Read only

0 Likes
2,948

Hi Prasenjit,

I have written code below : condition record is updated but when I check the record through tcode MEK2, "valid from date" is not getting updated.

Is there anything else to be done in the code ??

   REPORT  ZGEQ_TEST.

PARAMETERS: p_KBETR type KBETR DEFAULT '99'.
*PARAMETERS: p_KNUMA type KNUMA_AG DEFAULT 'X000009996'.
PARAMETERS: p_datef type sy-datum DEFAULT '20130401'.
PARAMETERS: p_datet type sy-datum DEFAULT '20130731'.
*PARAMETERS: p_kunnr TYPE kunnr DEFAULT '28523272'.
PARAMETERS: p_matnr type matnr DEFAULT 'P7734527'.
PARAMETERS: p_werks type werks DEFAULT '8001'.

START-OF-SELECTION.

DATA:
cr LIKE TABLE OF komv WITH HEADER LINE, " copy_records
nr, "New_Record
key_fields LIKE TABLE OF komg WITH HEADER LINE,
komk LIKE TABLE OF komk WITH HEADER LINE,
komp LIKE TABLE OF komp WITH HEADER LINE,
COPY_RECS_IDOC LIKE TABLE OF KOMV_IDOC WITH HEADER LINE,
i_kona TYPE kona.

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

* KOMK/KOMP Fuellen

*Fill KOMK

komk-mandt = '250'.
*komk-vkorg = '1310'.
*komk-vtweg = '01'.
*komk-spart = '01'.
*komk-kunnr = p_kunnr.
komk-kappl = 'M'.
komk-werks = p_werks.
komk-ERDAT = sy-datum.
komp-kposn = '000001'.
komp-matnr = p_matnr.
*komp-KNUMA_AG = p_KNUMA.
komp-kposn = '000001'.

key_fields-mandt  = '250'.
*key_fields-vkorg = '3376'.
*key_fields-kunnr = p_kunnr.
*key_fields-vtweg = '01'.
*key_fields-spart = '01'.
key_fields-matnr p_matnr.

cr-kappl = 'M'.
cr-kschl = 'ZGFB'.
cr-krech = 'C'.
cr-KBETR = p_KBETR.
cr-waers = 'INR'.
cr-kpein = 1.
cr-kmein = 'EA'.
cr-kopos = 01.
cr-kzbzg = 'C'.
*cr-knumh = '0005014306'.
APPEND cr.

i_kona-abtyp = 'C'.
*  i_kona-knuma  =  p_knuma.
*COPY_RECS_IDOC-KNUMA_AG = p_KNUMA.
*append COPY_RECS_IDOC.

CALL FUNCTION 'RV_CONDITION_RESET'.

* --> KOMK/KOMP werden korrekt gef#llt. Funktion i.o.

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

CALL FUNCTION 'RV_CONDITION_COPY'
  EXPORTING
    application              = 'M'
    condition_table          = '915'
    condition_type           = 'ZGFB'
    date_from                = p_datef
    date_to                  = p_datet
    enqueue                  = 'X'
    i_komk                   = komk
    i_komp                   = komp
    key_fields               = key_fields
    maintain_mode            = 'B'
*    no_authority_check       = space
    no_field_check           = 'X'
    keep_old_records         = space
*    overlap_confirmed        = 'X'
    i_kona                   = i_kona
*    SELECTION_DATE           = sy-datum
  IMPORTING
    e_komk                   = komk
    e_komp                   = komp
    new_record               = nr
  TABLES
    copy_records             = cr
    COPY_RECS_IDOC           = COPY_RECS_IDOC
  EXCEPTIONS
    enqueue_on_record        = 01
    invalid_application      = 02
    invalid_condition_number = 03
    invalid_condition_type   = 04
    no_authority_ekorg       = 05
    no_authority_kschl       = 06
    no_authority_vkorg       = 07
    no_selection             = 08
    table_not_valid          = 09.

CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.
commit work.

Read only

0 Likes
2,948

Hi Santosh,

Please try to pass value  MAINTAIN_MODE = 'A'. and run your program.

Regards,

Prasenjit

Read only

0 Likes
2,948

Hi Prasenjit,

My requirement is to change the existing condition record and not to append... so i used 'B'.  What I have observed is that except Valid From Date every other field gets changed.. but valid from date remains same.

Is it that we cannot change valid from date through this FM if we want to change the existing condition record ??

Regards,

Santosh

Read only

0 Likes
2,948

If I use 'A', then it creates a new record which is not my requirement...

Read only

0 Likes
2,948

Hi Santosh ,

After 'RV_CONDITION_COPY' FM , Please change date using FM RV_CONDITION_MAINTENANCE.

Please try this and let me know.

Thanks,

Prasenjit

Read only

0 Likes
2,948

Hi Prasenjit,

I have used FM 'RV_CONDITION_MAINTENANCE' but getting error "

Condition type ZGFB does not allow supplementary conditions"

   CALL FUNCTION 'RV_CONDITION_MAINTENANCE'
  EXPORTING
    application                    = 'M'
    CONDITION_TABLE                = '915'
    CONDITION_TYPE                 = 'ZGFB'
    DATE_FROM                      = p_datef
    DATE_TO                        = p_datet
    ENQUEUE                        = 'X'
    I_KOMK                         = komk
    I_KOMP                         = komp
    key_fields                     = key_fields
    MAINTAIN_MODE                  = 'B'
IMPORTING
    E_KOMK                         = komk
    E_KOMP                         = komp
EXCEPTIONS
    ENQUEUE_ON_RECORD              = 1
    INVALID_APPLICATION            = 2
    INVALID_CONDITION_NUMBER       = 3
    INVALID_CONDITION_TYPE         = 4
    INVALID_CONDITION_TABLE        = 5
    NO_AUTHORITY_EKORG             = 6
    NO_AUTHORITY_KSCHL             = 7
    NO_AUTHORITY_VKORG             = 8
    NO_SELECTION                   = 9
    TABLE_NOT_VALID                = 10
    TERMINATED_BY_USER             = 11
    OTHERS                         = 12.


Read only

0 Likes
2,948

By using Export parameter in FM 'RV_CONDITION_MAINTENANCE  :-

FIRST_SCREEN             = 'D'

The error

Condition type ZGFB does not allow supplementary conditions"

is gone..

but the problem Valid From Date not getting updated remains ....

Read only

0 Likes
2,948

Now my final FM call looks like below.. but no success ...

   CALL FUNCTION 'RV_CONDITION_MAINTENANCE'
    EXPORTING
      application              = 'M'
      first_screen             = 'D'
      condition_table          = '915'
      condition_type           = 'ZGFB'
      date_from                = p_datef
      date_to                  = p_datet
      enqueue                  = 'X'
      i_komk                   = komk
      i_komp                   = komp
      key_fields               = key_fields
      maintain_mode            = 'B'
      context_requested        = 'X'
      SELECTION_DATE           = p_datef
    IMPORTING
      change_in_record         = kond_change
      save_requested           = kond_buch
      exit_requested           = kond_exit
      overlap_denied           = kond_overlap_denied
      e_komk                   = komk
      e_komp                   = komp
      e_datab                  = p_datef
      e_datbi                  = p_datet
    EXCEPTIONS
      enqueue_on_record        = 1
      invalid_application      = 2
      invalid_condition_number = 3
      invalid_condition_type   = 4
      invalid_condition_table  = 5
      no_authority_ekorg       = 6
      no_authority_kschl       = 7
      no_authority_vkorg       = 8
      no_selection             = 9
      table_not_valid          = 10
      terminated_by_user       = 11
      OTHERS                   = 12.

Read only

0 Likes
2,948

Hi Santosh,

what errors come after run this FM?

are u used RV_CONDITION_SAVE FM after your FM?

Regards,

Prasenjit

Read only

0 Likes
2,948

No error comes.. program gets executed successfully.. but unfortunately Validity from date not getting updated...

I am pasting my source code..

   *&---------------------------------------------------------------------*
*& Report  ZGEQ_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zgeq_test.

PARAMETERS: p_kbetr TYPE kbetr DEFAULT '99'.
*PARAMETERS: p_KNUMA type KNUMA_AG DEFAULT 'X000009996'.
PARAMETERS: p_datef TYPE sy-datum DEFAULT '20130401'.
PARAMETERS: p_datet TYPE sy-datum DEFAULT '20130731'.
*PARAMETERS: p_kunnr TYPE kunnr DEFAULT '28523272'.
PARAMETERS: p_matnr TYPE matnr DEFAULT 'P7734527'.
PARAMETERS: p_werks TYPE werks DEFAULT '8001'.

START-OF-SELECTION.

  DATA:
  cr LIKE TABLE OF komv WITH HEADER LINE, " copy_records
  nr, "New_Record
  key_fields LIKE TABLE OF komg WITH HEADER LINE,
  komk LIKE TABLE OF komk WITH HEADER LINE,
  komp LIKE TABLE OF komp WITH HEADER LINE,
  copy_recs_idoc LIKE TABLE OF komv_idoc WITH HEADER LINE,
  i_kona TYPE kona.

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

* KOMK/KOMP Fuellen

*Fill KOMK

  komk-mandt = '250'.
*komk-vkorg = '1310'.
*komk-vtweg = '01'.
*komk-spart = '01'.
*komk-kunnr = p_kunnr.
  komk-kappl = 'M'.
  komk-werks = p_werks.
  komk-erdat = sy-datum.
  komp-kposn = '000001'.
  komp-matnr = p_matnr.
*komp-KNUMA_AG = p_KNUMA.
  komp-kposn = '000001'.
  komp-werks = p_werks.

  key_fields-mandt  = '250'.
*key_fields-vkorg = '3376'.
*key_fields-kunnr = p_kunnr.
*key_fields-vtweg = '01'.
*key_fields-spart = '01'.
  key_fields-matnr p_matnr.

  cr-kappl = 'M'.
  cr-kschl = 'ZGFB'.
  cr-krech = 'C'.
  cr-kbetr = p_kbetr.
  cr-waers = 'INR'.
  cr-kpein = 1.
  cr-kmein = 'EA'.
  cr-kopos = 01.
  cr-kzbzg = 'C'.
*cr-knumh = '0005014306'.
  cr-kdatu = p_datef.
  APPEND cr.

  i_kona-abtyp = 'C'.
  i_kona-datab = p_datef.
  i_kona-datbi = p_datet.
*  i_kona-knuma  =  p_knuma.
*COPY_RECS_IDOC-KNUMA_AG = p_KNUMA.
*append COPY_RECS_IDOC.

  CALL FUNCTION 'RV_CONDITION_RESET'.

* --> KOMK/KOMP werden korrekt gef#llt. Funktion i.o.

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

  CALL FUNCTION 'RV_CONDITION_COPY'
    EXPORTING
      application              = 'M'
      condition_table          = '915'
      condition_type           = 'ZGFB'
      date_from                = p_datef
      date_to                  = p_datet
      enqueue                  = 'X'
      i_komk                   = komk
      i_komp                   = komp
      key_fields               = key_fields
      maintain_mode            = 'A'
*    no_authority_check       = space
      no_field_check           = 'X'
      keep_old_records         = space
*    overlap_confirmed        = 'X'
      i_kona                   = i_kona
*    SELECTION_DATE           = sy-datum
    IMPORTING
      e_komk                   = komk
      e_komp                   = komp
      new_record               = nr
    TABLES
      copy_records             = cr
      copy_recs_idoc           = copy_recs_idoc
    EXCEPTIONS
      enqueue_on_record        = 01
      invalid_application      = 02
      invalid_condition_number = 03
      invalid_condition_type   = 04
      no_authority_ekorg       = 05
      no_authority_kschl       = 06
      no_authority_vkorg       = 07
      no_selection             = 08
      table_not_valid          = 09.

  DATA :   kond_change,
           kond_buch,
           kond_exit,
           kond_overlap_denied.

  CALL FUNCTION 'RV_CONDITION_MAINTENANCE'
    EXPORTING
      application              = 'M'
      first_screen             = 'D'
      condition_table          = '915'
      condition_type           = 'ZGFB'
      date_from                = p_datef
      date_to                  = p_datet
      enqueue                  = 'X'
      i_komk                   = komk
      i_komp                   = komp
      key_fields               = key_fields
      maintain_mode            = 'B'
      context_requested        = 'X'
      SELECTION_DATE           = p_datef
    IMPORTING
      change_in_record         = kond_change
      save_requested           = kond_buch
      exit_requested           = kond_exit
      overlap_denied           = kond_overlap_denied
      e_komk                   = komk
      e_komp                   = komp
      e_datab                  = p_datef
      e_datbi                  = p_datet
    EXCEPTIONS
      enqueue_on_record        = 1
      invalid_application      = 2
      invalid_condition_number = 3
      invalid_condition_type   = 4
      invalid_condition_table  = 5
      no_authority_ekorg       = 6
      no_authority_kschl       = 7
      no_authority_vkorg       = 8
      no_selection             = 9
      table_not_valid          = 10
      terminated_by_user       = 11
      OTHERS                   = 12.

  CALL FUNCTION 'RV_CONDITION_SAVE'.
  CALL FUNCTION 'RV_CONDITION_RESET'.
  COMMIT WORK.