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: 

CALL FUNCTION 'SD_COND_ACCESS' Problem

Former Member
0 Kudos

Dear Gurus ,

I try to read a condition type .

When i try to exeute SD_COND_ACCESS for a condition type it works OK.

The condition type is 'ZCU'.

When i try to run for 'ZZN' it doesn work.

Can you give me a hint .

Look my code. ....

IF ZAAHEADMET-ZMETAL_TYPE = 'ZN_A' .
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'ZN_B' .
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'CU_A' .
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'CU_B' .
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'PB'.
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'AL'.
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) 'U' INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'NI'.
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ELSEIF ZAAHEADMET-ZMETAL_TYPE = 'SN'.
        CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.
      ENDIF.

*      CONCATENATE 'Z'ZAAHEADMET-ZMETAL_TYPE(2) INTO TEMP_KSCHL.

      TEMP_DATE = DATEITAB-DATES.


      JPISPR-MATNR = '000000021028053742' . "'000000021028016028'.
      JPISPR-VRKME = 'MTR'.   "TEMP_MEINS'.
      JPISPR-VKORG = '2200'.
      JPISPR-VTWEG = '20'.
      JPISPR-SPART = '10'.
      JPISPR-WAERK = 'USD'. "TEMP_WAERS.
      JPISPR-KUNNR = '25'.    "ZKUNNR'.
      JPISPR-VKALS = 'ZHALC1'.
      JPISPR-PRSDT = DATEITAB-DATES. "TEMP_DATE.
      JPISPR-KWAER = TEMP_WAERS.
      JPISPR-KURST = 'M'.


      CALL FUNCTION 'SPR_KOMK_KOMP_FILL'
        EXPORTING
          PI_I_SPR  = JPISPR
        IMPORTING
          PE_I_KOMK = KOMK_WA
          PE_I_KOMP = KOMP_WA
        EXCEPTIONS
          OTHERS    = 1.

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

      KOMP_WA-PRODH    = P_PRDHA.
      KOMP_WA-ZZPRODH1 = P_PRDHA(1).
      KOMP_WA-ZZPRODH2 = P_PRDHA+1(2).
      KOMP_WA-ZZPRODH3 = P_PRDHA+3(2).
      KOMP_WA-ZZPRODH4 = P_PRDHA+5(2).
      KOMP_WA-ZZPRODH5 = P_PRDHA+7(2).
      KOMP_WA-ZZPRODH6 = P_PRDHA+9(2).
      KOMP_WA-ZZMVGR1  = '001'.
      KOMP_WA-PMATN    = KOMP_WA-MATNR.

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

*      MOVE-CORRESPONDING KOMP_WA TO KOMP_WA_NEW.
*      MOVE-CORRESPONDING KOMK_WA TO KOMK_WA_NEW.
*      APPEND KOMP_WA_NEW .
*      APPEND KOMK_WA_NEW .

      CLEAR: KONDTAB, KONDTAB[].
      SELECT * FROM T685 WHERE KOZGF = TEMP_KSCHL.
        EXIT.
      ENDSELECT.


      CLEAR T682I.
      SELECT * FROM T682I INTO TABLE T682I_I WHERE KOZGF = TEMP_KSCHL.

      LOOP AT T682I_I.
        CALL FUNCTION 'SD_COND_ACCESS'
          EXPORTING
            APPLICATION          = 'V'
            CONDITION_TYPE       = TEMP_KSCHL
            DATE                 = DATEITAB-DATES
            HEADER_COMM_AREA     = KOMK_WA
            POSITION_COMM_AREA   = KOMP_WA
            PRESTEP              = 'X'
            T682I_I              = T682I_I
            KOPRT_I              = KOPRT
          TABLES
            CONDITION_RECORDS    = KONDTAB
          EXCEPTIONS
            FIELD_IS_INITIAL     = 1
            NOT_READ_UNQUALIFIED = 2
            READ_BUT_NOT_FOUND   = 3
            READ_BUT_BLOCKED     = 4
            T682Z_MISSING        = 5
            T681V_MISSING        = 6
            T681Z_MISSING        = 7
            MVA_ERROR            = 8
            OTHERS               = 9.
        CHECK SY-SUBRC = 0.
        READ TABLE KONDTAB INDEX 1.
        CHECK SY-SUBRC = 0.

        SELECT * FROM KONP INTO KONP_WA WHERE KNUMH = KONDTAB-KNUMH.
          EXIT.
        ENDSELECT.

        CHECK SY-SUBRC = 0.

        ITAB_ZCU-KBETR = KONP_WA-KBETR.
        APPEND ITAB_ZCU.

        CLEAR: KONDTAB, KONDTAB[].
        EXIT.

Thanks a lot...

1 ACCEPTED SOLUTION

arseni_gallardo
Active Participant
0 Kudos

And unless the name of the access sequence is exactly the same as the name of condtion name you have an error in your code:

Substitute this


    SELECT * FROM T682I INTO TABLE T682I_I WHERE KOZGF = TEMP_KSCHL.

with


    SELECT * FROM T682I INTO TABLE T682I_I WHERE KOZGF = t685-kozgf AND kvewe EQ 'A' and kappl eq 'V'.

9 REPLIES 9

arseni_gallardo
Active Participant
0 Kudos

What do you mean when you say that it does not work? Did you expect your code to find a condition record for ZZN but it didn't? If that's the case may be the problem is that the access sequence needs more info, or that there is no condition record at all.

I'd suggest you to go to transaction VK13, press the 'Condition info' button and supply there the same info your are feeding in your program. That way you will know if there are condition records.

arseni_gallardo
Active Participant
0 Kudos

And unless the name of the access sequence is exactly the same as the name of condtion name you have an error in your code:

Substitute this


    SELECT * FROM T682I INTO TABLE T682I_I WHERE KOZGF = TEMP_KSCHL.

with


    SELECT * FROM T682I INTO TABLE T682I_I WHERE KOZGF = t685-kozgf AND kvewe EQ 'A' and kappl eq 'V'.

0 Kudos

I Did the substitution the you suggested me but it doesn't work.

The sy-subrc = 3 .

Read but not find ....

0 Kudos

Well, that means that there is no condition record that meets the criteria (or one is found but marked for deletion). May be there is no coding problem at all. Have you checked in transaction VK13?

0 Kudos

The problem is that i have the same access sequence with different condition table.

When i run it with T682I_I-KOTABNR = '600' it plays for both ......

0 Kudos

And why is that a problem? It is a very normal situation.

0 Kudos

Actually i dont know why this is problem . I am not SD .

But the hint that you give me hepled me and i solved the problem ...

I always pass the value T682I_I-KOTABNR = '600' and not 601 , 602 , 603 ....

0 Kudos

But your solution may be wrong. If the access sequence has N steps (600, 601, 602 ...) you can not expect to always find the condition in table 600. You'd better sit with your SD consultant and discuss the problem with him.

0 Kudos

i Know .We will sit and check it.