SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Зависимость bkpf-awkey и bkpf-awtyp



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Рустам
Специалист
Специалист



Joined: 26 Dec 2007
Posts: 73

PostPosted: Tue Dec 02, 2008 8:48 pm    Post subject: Зависимость bkpf-awkey и bkpf-awtyp Reply with quote

Коллеги, приходилось ли кому-нибудь решать следующую задачу.
В зависимости от значения bkpf-awtyp, bkpf-awkey формируется по разному. Иногда он состоит только из номера документа, иногда номера и года, а иногда из номера, года и кода компании. Как универсально составлять ключ, зная все эти три параметра, основываясь на значении bkpf-awtyp?
Back to top
View user's profile Send private message
ghost
Специалист
Специалист


Age: 37
Joined: 18 Jan 2008
Posts: 71
Location: Tashkent-Astana-Moscow

PostPosted: Wed Dec 03, 2008 8:45 am    Post subject: Reply with quote

могу предположить что AWKEY собирается из ключевых полей таблицы которая указывается в AWTYP
Back to top
View user's profile Send private message Send e-mail Blog
vga
Мастер
Мастер


Age: 140
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Wed Dec 03, 2008 11:34 am    Post subject: Reply with quote

ghost wrote:
могу предположить что AWKEY собирается из ключевых полей таблицы которая указывается в AWTYP


Не совсем так, название awtyp не всегда соотвествует названию таблицы.

Справочная таблица для awtyp - TTYP.
В поле TTYP-STRUC содержится ссылка на структуру с описанием ключа. Если поле TTYP-STRUC пустое, в большинстве случаев ключ состоит из номера документа (могут быть исключения, у нас, например CAJO).

Накидал пример:
Code:
FUNCTION zeru_awtyp_2_awkey.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(I_AWTYP) TYPE  AWTYP
*"     VALUE(I_BELNR) TYPE  BELNR_D
*"     VALUE(I_GJAHR) TYPE  GJAHR OPTIONAL
*"     VALUE(I_BUKRS) TYPE  BUKRS OPTIONAL
*"     VALUE(I_AWORG) TYPE  AWORG OPTIONAL
*"  EXPORTING
*"     VALUE(E_AWKEY) TYPE  AWKEY
*"  EXCEPTIONS
*"      NOT_FOUND
*"      KEY_INCORRECT
*"----------------------------------------------------------------------

  DATA: ls_ttyp TYPE ttyp.
  DATA: it_dfies LIKE dfies OCCURS 0 WITH HEADER LINE,
        l_tabname TYPE  ddobjname.
  IF i_awtyp IS INITIAL.
    RAISE not_found.
  ENDIF.

  IF i_awtyp EQ 'CAJO'.
    CONCATENATE i_belnr i_aworg INTO e_awkey.
    EXIT.
  ENDIF.

  SELECT SINGLE * INTO ls_ttyp
  FROM ttyp WHERE awtyp = i_awtyp.

  IF ls_ttyp-struc IS INITIAL.
    e_awkey = i_belnr.
    EXIT.
  ENDIF.

  l_tabname = ls_ttyp-struc.
  CALL FUNCTION 'DDIF_FIELDINFO_GET'
       EXPORTING
            tabname        = l_tabname
       TABLES
            dfies_tab      = it_dfies
       EXCEPTIONS
            not_found      = 1
            internal_error = 2
            OTHERS         = 3.

  LOOP AT it_dfies.
    CASE it_dfies-domname.
      WHEN 'BELNR'.
        CONCATENATE e_awkey i_belnr INTO e_awkey.
      WHEN 'GJAHR'.
        CONCATENATE e_awkey i_gjahr INTO e_awkey.
      WHEN 'BUKRS'.
        CONCATENATE e_awkey i_bukrs INTO e_awkey.
      WHEN OTHERS.
        RAISE KEY_INCORRECT.
    ENDCASE.
  ENDLOOP.
ENDFUNCTION.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.