Posted: Fri Mar 26, 2010 2:34 pm Post subject: Как по номеру документа узначь, чем его просматривать
Здравствуйте!
Есть ли какая функция, чтобы по номеру документа узнать, какой транзакцией его просматривать (фин. док - MB03, документ закупки - me23n, и т.д.)? Это нужно для перехода из ALV GRID.
Age: 165 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Fri Mar 26, 2010 4:54 pm Post subject:
По номеру весьма проблематично.
Но зная тип документа (а его достать как правило легко), компани код и год, для большинства документов можно воспользоваться такой функцией.
Code:
FUNCTION ze_document_sender.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_AWTYP) LIKE ACCHD-AWTYP
*" VALUE(I_AWREF) LIKE ACCHD-AWREF
*" VALUE(I_AWORG) LIKE ACCHD-AWORG DEFAULT SPACE
*" VALUE(I_AWSYS) LIKE ACCHD-AWSYS DEFAULT SPACE
*" VALUE(I_BUKRS) LIKE ACCIT-BUKRS DEFAULT SPACE
*"----------------------------------------------------------------------
DATA: l_ttyp TYPE ttyp.
CHECK NOT i_awtyp IS INITIAL.
SELECT SINGLE * FROM ttyp INTO l_ttyp
WHERE awtyp = i_awtyp.
CHECK sy-subrc IS INITIAL.
CHECK NOT l_ttyp-function IS INITIAL.
CALL FUNCTION l_ttyp-function
EXPORTING
i_awtyp = i_awtyp
i_awref = i_awref
i_aworg = i_aworg
i_awsys = i_awsys
i_bukrs = i_bukrs.
ENDFUNCTION.
Code:
*&------------------------------------------------------------------*
*& Form user_command
*&------------------------------------------------------------------*
* Called on user_command ALV event.
* Executes custom commands.
*-------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: ls_output TYPE styp_output.
CASE r_ucomm.
WHEN '&IC1'.
*dbl. click processing
*get selected item
READ TABLE it_output INDEX rs_selfield-tabindex INTO ls_output.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CASE rs_selfield-fieldname.
WHEN 'DOCNR'.
SET PARAMETER ID 'BUK' FIELD p_bukrs.
SET PARAMETER ID 'GDN' FIELD ls_output-docnr.
SET PARAMETER ID 'GLN' FIELD 'R1'.
SET PARAMETER ID 'GJR' FIELD p_year.
CALL TRANSACTION 'GD23' AND SKIP FIRST SCREEN.
WHEN 'REFDOCNR'.
DATA: l_awtyp TYPE acchd-awtyp,
l_awref TYPE acchd-awref,
l_aworg TYPE acchd-aworg.
IF ls_output-awtyp EQ 'BKPF' OR
ls_output-awtyp EQ 'IBKPF' OR
ls_output-awtyp EQ 'BKPFF' OR
ls_output-awtyp EQ 'GLAL0'.
l_aworg = p_bukrs.
ENDIF.
CONCATENATE l_aworg p_year INTO l_aworg.
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.