Skip to content

Commit

Permalink
Static Value Helps: frontend part abap-value-help
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Mar 23, 2021
1 parent 4b22914 commit f62f4af
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 30 deletions.
36 changes: 34 additions & 2 deletions abap-value-help/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-f8bc45.svg)](https://github.com/prettier/prettier)

Generic Value Helps for [conventions' based applications](https://github.com/SAP/fundamental-tools/blob/main/doc/app.md) and front-ends supported by [Fundamental Library for ABAP](https://github.com/SAP/fundamental-tools)
Generic Value Helps for [conventions' based applications](https://github.com/SAP/fundamental-tools/blob/main/doc/app.md), supported by [Fundamental Library for ABAP](https://github.com/SAP/fundamental-tools)

- ABAP API, well-known to SAPGUI developers:
- ABAP Fixed Domain Values (FV)
- ABAP Elementary and complex Search Helps (SH)
- ABAP Check Tables (CT, CH)
- Custom value helps

- [Installation](#installation)
- [Usage](#usage)
- [Dynamic Value Help dialog](#dynamic-value-help-dialog)
- [Static Value Help dialog](#static-value-help-dialog)
- [Components](#components)
- [ABAP API](#abap-api)
- [Server](#server)
Expand All @@ -35,6 +38,9 @@ ABAP API: [doc/abap](https://github.com/SAP/fundamental-tools/blob/main/abap-val

## Usage

- SCN blog: [Generic ABAP Value Helps using Fundamental Library for ABAP and Web Components](https://blogs.sap.com/2021/03/02/generic-abap-value-helps-powered-by-fundamental-library-for-abap-and-web-components/)


- Expose generic Value Help routes: [#server](#server)

- Register generic Value Help dialog in your application: [#view-model-and-view](#view-model-and-view)
Expand All @@ -61,10 +67,36 @@ ABAP API: [doc/abap](https://github.com/SAP/fundamental-tools/blob/main/abap-val
></ui-input>
```

Custom attribute will add Search Help icon input addon and run the Search Help dialog using abovementioned routes. Input ui component is updated with the Search Help dialog result:
### Dynamic Value Help dialog

Custom attribute will add Search Help icon input addon and create and open the Search Help dialog on user request. Input ui component is updated with the Search Help dialog result:

![dialog](https://raw.githubusercontent.com/SAP/fundamental-tools/main/abap-value-help/doc/assets/ValueInputHelpsDialog.jpg)

Dynamically created dialog requires no development efforts but has restrictions:

- Some elementary Value Helps return search errors they return, like "Dynpro sent in background ...".
Array of their id-s should be passed via `shlp.blacklist`, as shown above, to prevent their usage.
Low effort to add the id but each Value Help search should be tested upfront.

- Value Help selection parameters lack Value Helps for themselves

### Static Value Help dialog

Static Value Help dialogs come to the rescue. Automatically generated in design-time, they do not have above mentioned limitations and can be manually fine-tuned. Activated the same way via custom attribute.

Use the [abap-api-tools](https://github.com/SAP/fundamental-tools/blob/main/abap-api-tools/README.md) `-h` option to parse Value Help descriptors (`get` command) and generate static Value Help dialogs (`make` command).

All Value Helps are automatically tested and in case of search errors, black-listed with the error message.

```shell
abap get MME -c config/equipment -h

abap make aurelia -c config/all -h
```

One `html` and one `js` file is generated for each elementary Value Help and written into `valueHelps` folder.

## Components

Value Help is enabled for the ui component by binding custom attribute `shlp` to Value Help id like `{type: 'SH', id: 'IFLM'}`:
Expand Down
4 changes: 2 additions & 2 deletions abap-value-help/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion abap-value-help/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "abap-value-help",
"description": "ABAP Value Help",
"version": "0.9.6",
"version": "1.0.0",
"homepage": "https://github.com/sap/fundamental-tools",
"author": "SAP",
"license": "Apache-2.0",
Expand Down
78 changes: 53 additions & 25 deletions abap-value-help/src/ts/valueInputHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function isEmpty(obj?: unknown[] | Record<string, unknown>): boolean {
export type ValueHelpError = Record<string, unknown>;

export type FVDescriptorType = {
type: string;
valueInputType: string;
count: number;
values: Record<string, string>;
customCheckbox?: boolean;
Expand Down Expand Up @@ -127,11 +127,14 @@ export interface IValueHelpFound {
//descriptor: DescriptorType;
}

export type ElementaryHelpsList = Record<string, string>[];
export type ElementaryHelpsList = Record<
string,
{ title: string; blacklist?: { selection: string } | { search: string } }
>;

export type ValueHelpType = {
title: string;
elementaryHelps?: ElementaryHelpsList;
elementaryHelps?: ElementaryHelpsList[];
};

// export interface IValueHelpDetermine {
Expand Down Expand Up @@ -224,7 +227,7 @@ export class ValueInputHelp {
}

Descriptors[helpFound.id] = {
type: shlp_values.length > 2 ? "list" : "binary",
valueInputType: shlp_values.length > 2 ? "list" : "binary",
count: Object.keys(domainValues).length,
values: domainValues,
};
Expand Down Expand Up @@ -276,15 +279,27 @@ export class ValueInputHelp {
// SH
//
case "SH": {
const ET_SHLP = (
await this.client.call(this.shlpApi.SH_descriptor_get, {
IV_SHLPTYPE: helpFound.SHLPTYPE,
IV_SHLPNAME: helpFound.SHLPNAME,
})
).ET_SHLP as RfcTable;
let ET_SHLP: RfcTable = [];

try {
ET_SHLP = (
await this.client.call(this.shlpApi.SH_descriptor_get, {
IV_SHLPTYPE: helpFound.SHLPTYPE,
IV_SHLPNAME: helpFound.SHLPNAME,
})
).ET_SHLP as RfcTable;
} catch (ex) {
if (!Descriptors[helpFound.id]) {
Descriptors[helpFound.id] = {
blacklist: "selection",
selectionDescriptor: ex,
};
}
log.debug(`Descriptor selection error`, helpFound.id, ex.message);
}

// elementary helps
const elementaryList: ElementaryHelpsList = [];
const elementaryList: ElementaryHelpsList[] = [];

for (const desc of ET_SHLP) {
// elementary id may differ
Expand All @@ -294,7 +309,6 @@ export class ValueInputHelp {
: `${desc.SHLPTYPE} ${desc.SHLPNAME}`;

const title = (desc.INTDESCR as RfcStructure).DDTEXT as string;
elementaryList.push({ [shlp_key]: title });

// elementary help
if (!Helps[shlp_key]) {
Expand Down Expand Up @@ -344,19 +358,32 @@ export class ValueInputHelp {
D.blacklist = "search";
D.resultDescriptor = ex;
log.debug(`Value Help search error: ${shlp_key} `, ex);
} finally {
const el: ElementaryHelpsList = {
[shlp_key]: { title: title },
};
if (D.blacklist) {
el[shlp_key].blacklist = {
[D.blacklist]: (D.resultDescriptor as ValueHelpError)
.message as string,
};
}
elementaryList.push(el);
}
}
} else {
elementaryList.push({ [shlp_key]: { title: title } });
}
}

// consistency check
if (ET_SHLP.length > 1) {
if (!Helps[helpFound.id]["elementaryHelps"]) {
Helps[helpFound.id]["elementaryHelps"] = elementaryList;
}
} else {
if (helpFound.id && !Descriptors[helpFound.id]) {
log.error("Descriptor not saved for", helpFound.id);
}
// consistency check
if (ET_SHLP.length > 1) {
if (!Helps[helpFound.id]["elementaryHelps"]) {
Helps[helpFound.id]["elementaryHelps"] = elementaryList;
}
} else {
if (helpFound.id && !Descriptors[helpFound.id]) {
log.error("Descriptor not saved for", helpFound.id);
}
}

Expand Down Expand Up @@ -422,14 +449,15 @@ export class ValueInputHelp {

// add domain CT if no other shelp found
if (dfies["DOMNAME"] && !helpFound.SHLPTYPE) {
const domain_ct = ((
const DD01V_WA_A = (
await this.client.call("DD_DOMA_GET", {
DOMAIN_NAME: dfies.DOMNAME,
})
).DD01V_WA_A as RfcStructure).ENTITYTAB as string;
if (domain_ct) {
).DD01V_WA_A as RfcStructure;
if (DD01V_WA_A.ENTITYTAB as string) {
helpFound.SHLPTYPE = "CT";
helpFound.SHLPNAME = domain_ct;
helpFound.SHLPNAME = DD01V_WA_A.ENTITYTAB as string;
helpFound.title = DD01V_WA_A.DDTEXT as string;
}
}

Expand Down

0 comments on commit f62f4af

Please sign in to comment.