SAP ABAP 教程:如何限制 BW Query 中的 F4 输入帮助值

作者:郑德鼎 约 5 分钟阅读 更新日期:2024-02-22 2 年前更新 标签:ABAP, Data Engineering, SD, 开发, 数据工程, 销售分销
目录

在 SAP BW/BI 报表中,F4 输入帮助(Input Help)为用户提供了快速选择值的入口。但在实际项目中,经常需要根据用户权限或业务规则限制 F4 列表中的可选值。本文介绍如何在 BW Query 运行时限制 F4 值,并给出 ABAP 实现思路。

Restricting F4 (Input Help) Values

While Running a SAP BW Query

Applies to

SAP BI 7.01

Summary

This article briefs out the way to restrict F4 values (Input help values) while running a SAP BW query with the

help of BADI RSR_VARIABLE_F4_RESTRICT_BADI. This feature was not available with previous versions

of SAP BW (before SAP BW 7.01, SP 9).

Author: Amandeep Sharma

Company: Australand Property Group, Australia

Created on: 1st October 2011

Author Bio

Amandeep Sharma is working as a Senior BW/BI Developer in Australian company

Australand Property Group. He has more than 6 years of SAP BW/BI/BO experience. He

has worked on various support/implementation projects while working in consulting

companies like SAP Labs India, IBM India, and HCL Axon Australia. Currently, he is

involved in SAP BW green field implementation in Australand Property Group, Australia.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 1

Restricting F4 (Input Help) Values While Running a SAP BW Query

Table of Contents

Introduction ......................................................................................................................................................... 3

Business Scenario .............................................................................................................................................. 3

Solution ............................................................................................................................................................... 4

Result ............................................................................................................................................................. 10

Related Content ................................................................................................................................................ 11

Disclaimer and Liability Notice .......................................................................................................................... 12

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 2

Restricting F4 (Input Help) Values While Running a SAP BW Query

Introduction

While running a SAP BW query, sometimes F4 help (Variable input help) returns a long list of unwanted

values. Users may not be interested to see all the returned values and this may confuse users or waste a lot

of time while selecting a right value from the list. There was no way to restrict the input help values before

SAP BI 7.01. With Support Package SAPKW70109 SAP has provided BADI

RSR_VARIABLE_F4_RESTRICT_BADI.

BADI RSR_VARIABLE_F4_RESTRICT_BADI has 3 methods as given in below screen shot.

In this document we will explain how to enhance this BADI to restrict F4 values. This document will discuss

GET_RESTRICTION_FLAT method which can be used to restrict the input help values for simple

characteristics variables.

Business Scenario

Let’s take one simple scenario where we can use RSR_VARIABLE_F4_RESTRICT_BADI BADI to restrict

input help values.

For a simple Fiscal Year Period Variable, it can display a number of fiscal periods when user hits F4 as

below

But users only want to see fiscal periods of last year.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 3

Restricting F4 (Input Help) Values While Running a SAP BW Query

Solution

Go to SPRO and execute the IMG activity “BAdI: Restricting the value help in the Variables Screen” as

below

Following screen will display any existing active implementation of BADI

RSR_VARIABLE_F4_RESTRICT_BADI.

Click on . Below message will appear.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 4

Restricting F4 (Input Help) Values While Running a SAP BW Query

Click on .

Give implementation name and give description of the implementation for your reference.

Click ok. In the below screen give RSR_VARIABLE_F4_RESTRICT_BADI as BAdI implementation name

and ZF4TEST as class name and click ok as below

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 5

Restricting F4 (Input Help) Values While Running a SAP BW Query

In the below screen select given row.

Click on . Below screen will appear

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 6

Restricting F4 (Input Help) Values While Running a SAP BW Query

Double click on .Below screen will appear

Now we can see three methods in class ZF4TEST of BADI RSR_VARIABLE_F4_RESTRICT_BADI.

Double click on method GET_RESTRICTION_FLAT. You can see below example code has been given by

SAP.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 7

Restricting F4 (Input Help) Values While Running a SAP BW Query

'ZP_TestFPVar' is the variable for which input help values will be restricted.)

'ZTest_Query' is the technical name of the query for which you want to restrict the input values.

Comment above code and write your code as below

DATA: lv_year TYPE n LENGTH 4,

lv_fiscalperiodlow TYPE /bi0/oifiscper,

lv_fiscalperiodhigh TYPE /bi0/oifiscper.

IF i_vnam EQ ‘ZP_TestFPVar'. READ TABLE i_t_compid WITH TABLE KEY table_line = 'ZTest_Query'

TRANSPORTING NO FIELDS.

IF sy-subrc = 0. lv_year1 = sy-datum+0(4) - 1.

CONCATENATE lv_year ‘001’ INTO lv_fiscalperiodlow .

CONCATENATE lv_year ‘012’ INTO lv_fiscalperiodhigh .

l_s_range-iobjnm = i_iobjnm.

l_s_range-sign = 'I'.

l_s_range-option = 'BT'.

l_s_range-low = lv_fiscalperiodlow. l_s_range-high = lv_fiscalperiodhigh. APPEND l_s_range TO c_t_range. ENDIF.

After activating the code, go back to enhancement Implementation screen.

Click on .

Click on . Below screen will appear.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 8

Restricting F4 (Input Help) Values While Running a SAP BW Query

Click on and enter IO 0FISCPER as below

Click ok.

Now we have defined the InfoObject for which this BADI will be called.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 9

Restricting F4 (Input Help) Values While Running a SAP BW Query

Result

Now run your query 'ZTest_Query' and you will notice input values have been restricted to only last year

fiscal periods as below

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 10

Restricting F4 (Input Help) Values While Running a SAP BW Query

Related Content

For more information please go through these URLs

https://service.sap.com/sap/support/notes/1416952

https://service.sap.com/sap/support/notes/1461962

http://help.sap.com/saphelp_nw73/helpdata/en/22/1e9b3c334d8c15e10000000a114084/content.htm

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 11

Restricting F4 (Input Help) Values While Running a SAP BW Query

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not

supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,

and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or

code sample, including any liability resulting from incompatibility between the content within this document and the materials and

services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this

document.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 12

郑德鼎

关于作者:郑德鼎

企业信息化与 SAP 技术顾问,长期专注 SAP ABAP、FI/CO、MM、SD 等模块的技术分享与实战经验总结。查看更多介绍

来源说明:本文内容由「Restricting F4 (Input Help) Values While Running a SAP BW Query.pdf」整理生成,仅用于内部技术分享与学习交流。