четверг, 3 октября 2013 г.

ФИО по логину пользователя



Функциональный  модуль, который возвращает ФИО пользователя (бывает полезно для печатных форм).
Код
FUNCTION zf_get_fio. *"---------------------------------------------------------------------- *"*"Локальный интерфейс: *" IMPORTING *" REFERENCE(UNAME) TYPE SYUNAME *" EXPORTING *" REFERENCE(SHORT_NAME) TYPE AD_NAMTEXT *" REFERENCE(LONG_NAME) TYPE AD_NAMTEXT *"---------------------------------------------------------------------- DATA: lv_name_text TYPE ad_namtext, lv_name_first TYPE ad_namefir, lv_name_first1 TYPE ad_namefir, lv_name_first2 TYPE ad_namefir, lv_name_last TYPE name_last, itab TYPE TABLE OF string. DATA: lv_uname TYPE bapibname-bapibname, lt_return TYPE STANDARD TABLE OF bapiret2, ls_return TYPE bapiret2, ls_address LIKE bapiaddr3. CHECK uname IS NOT INITIAL. CLEAR: ls_address, short_name, long_name, lt_return, lt_return[]. CALL FUNCTION 'BAPI_USER_GET_DETAIL' EXPORTING username = uname IMPORTING address = ls_address TABLES return = lt_return. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'. EXIT. ENDLOOP. CONCATENATE ls_address-lastname ls_address-firstname INTO long_name SEPARATED BY space. SPLIT ls_address-firstname AT space INTO: lv_name_first1 lv_name_first2, TABLE itab. CONCATENATE ls_address-lastname lv_name_first1+0(1) INTO lv_name_text SEPARATED BY space. CONCATENATE lv_name_text '.' INTO lv_name_text. IF lv_name_first2 IS NOT INITIAL. CONCATENATE lv_name_text lv_name_first2+0(1) '.' INTO lv_name_text. ENDIF. IF lv_name_text IS NOT INITIAL. short_name = lv_name_text. ENDIF. ENDFUNCTION.

Комментариев нет:

Отправить комментарий