Skip to content

Commit

Permalink
only table row definition is mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Jan 28, 2021
1 parent d836dad commit 112945a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 58 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Command line tool for pattern based web applications with ABAP/HANA systems and any ui framework.

- Any old or new ABAP system
- Any new or old SAP system
- Front-end frameworks:
- [Aurelia](http://aurelia.io/)
- Angular, React and Vue by [SAP Fundamenal Library](https://sap.github.io/fundamental/)
Expand Down
46 changes: 23 additions & 23 deletions abap-api-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Command line tool for pattern based applications with ABAP/HANA systems and any ui framework.

- BAPI/RFM call templates
- [BAPI/RFM](https://sap.github.io/cloud-sdk/docs/java/features/bapi-and-rfc/bapi-and-rfc-overview/) call templates
- ui components'with ABAP data annotations:
- [Aurelia](http://aurelia.io/)
- Angular, React and Vue by [SAP Fundamenal Library](https://sap.github.io/fundamental/)
Expand Down Expand Up @@ -87,14 +87,20 @@ abap call

### ABAP Function Module call template

NodeJS call template of single ABAP function module.
NodeJS call template of a single ABAP function module.

Echoed to console or saved to `bapi_user_get_details.js` when the `-s` option given:
Echoed to console or saved to local `js` file if the `-s` option is used:

```shell
abap call MME stfc_connection -s
abap call MME stfc_structure -s
```

The call template provides a source code for ABAP function module invocaton, with all parameters and their data structures:

- Optional parameters are commented and initialized with ABAP default values
- Required parameters are initialized with empty string, buffer or zero number
- Conversion ("ALPHA") exit, if attached to data element, is mentioned in data element comment

More than one ABAP function module

```shell
Expand Down Expand Up @@ -175,20 +181,16 @@ After annotations are saved, ui elements can be created:
abap make fudamental-ngx -c my-api # .yaml extension optional
```

Now we have one `js` file and one `html` file for each ABAP function module:
Now we have one `js` file with a call template one `html` file with ui components, for each ABAP function module:

```shell
bapi_whse_to_get_detail.js
bapi_whse_to_get_detail.html
```

The **js file** is ABAP function module call template, with all parameters and data structure reset values:
The `html` file contains ui components' templates, for each BAPI/RFM parameter and structure/table data field.

- Optional parameters are commented and initialized with ABAP default values
- Required parameters are initialized with standard defaults, like empty string or zero number
- Conversion ("ALPHA") exit, if attached to data element, is mentioned in data element comment

The **html file** contains ui component template, for each BAPI/RFM parameter and structure/table data field. Components are annoted with:
Annoted with:

- Data type, length
- Texts (label, caption)
Expand All @@ -199,31 +201,31 @@ The **html file** contains ui component template, for each BAPI/RFM parameter an
Ui components look like this (Aurelia example):

```html
<ui-input value.bind="DATA_GENERAL.DISTR_CHAN" shlp.bind='{type:"SH", id:"CSH_TVTW"}'
data-abap.bind='{type:"CHAR", length:"2", mid:"VTW"}'
<ui-input bind="DATA_GENERAL.DISTR_CHAN" shlp.bind="{type: 'SH', id: 'CSH_TVTW'}"
data-abap.bind="{type:'CHAR', mid:'VTW', length:'2'}"
label="Distribution Channel">
</ui-input>
<ui-checkbox value.bind="DATA_SPECIFIC.READ_CUREF" label="Referenced Configuration"></ui-checkbox>
<ui-date date.bind="DATA_FLEET.EXPIRY_DATE" label="Validity end date"></ui-date>
<ui-combo value.bind="DATA_GENERAL.COSTCENTER" shlp.bind='{type:"CT", id:"CSKS"}'
data-abap.bind='{type:"CHAR", length:"10", mid:"KOS", alpha: "ALPHA"}'
<ui-combo bind="DATA_GENERAL.COSTCENTER" shlp.bind="{type: 'CT', id: 'CSKS'}"
data-abap.bind="{type:'CHAR', alpha:'ALPHA', mid:'KOS', length:'10'}"
label="Cost Center">
</ui-combo>
<ui-combo value.bind="DATA_SPECIFIC.EQUICATGRY" shlp.bind='{type:"CT", id:"T370T"}'
data-abap.bind='{type:"CHAR", length:"1", mid:"EQT"}'
label="Equipment category">
<ui-combo bind="INSPROVIDER_X.IV_DISPATCH" shlp.bind="{type: 'FV', id: 'KUEVERS'}"
data-abap.bind="{type:'CHAR', length:'1'}"
label="IS-H: Send IV Request Only if Diagnosis Is Maintained">
</ui-combo>
```

## Custom ui configurations

Standard ui components' templates can be changed using local ui configuration.
Using two configuration files, you can map ABAP data types to your own ui components, for practically any ui framework.

Using copy command, the `ui5-react` configuration for example is copied to local config folder:
First copy the standard ui5-react configuration for example, to local config folder:

```shell
abap cp ui5-react
Expand All @@ -234,7 +236,7 @@ config
└── ui5-react.yaml
```

The configuration file with `-abap` suffix defines the mapping of ABAP data types to ui components:
The file with `-abap` suffix defines mapping of ABAP data types to ui components:

`ui5-react-abap.yaml`

Expand Down Expand Up @@ -262,8 +264,6 @@ datepicker: >-
</FormItem>
```

Using these two config files, you can map ABAP data types to your own ui components and use practically any ui framework.

Elements with tilde prefix `~` are placeholders for texts, data binding and value input helps, documented in `yaml` files.

Custom configuration in local config folder, if present, is used instead of the standard configuration. To go back to standard, remove it from `config` folder or run:
Expand Down
21 changes: 13 additions & 8 deletions abap-api-tools/package-lock.json

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

18 changes: 9 additions & 9 deletions abap-api-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "abap-api-tools",
"description": "ABAP api tools",
"version": "0.9.0",
"version": "0.9.1",
"homepage": "https://github.com/sap/fundamental-tools",
"author": "SAP",
"license": "Apache-2.0",
Expand Down Expand Up @@ -43,6 +43,14 @@
"node",
"nodejs"
],
"dependencies": {
"chalk": "^4.1.0",
"js-yaml": "^4.0.0",
"loglevel": "^1.7.1",
"node-rfc": "^2.4.0",
"sprintf-js": "^1.1.2",
"yargs": "^16.2.0"
},
"devDependencies": {
"@types/js-yaml": "^4.0.0",
"@types/node": "^14.14.22",
Expand All @@ -53,13 +61,5 @@
"eslint": "^7.18.0",
"jest": "^26.6.3",
"typescript": "^4.1.3"
},
"dependencies": {
"chalk": "^4.1.0",
"js-yaml": "^4.0.0",
"loglevel": "^1.7.1",
"node-rfc": "^2.4.0",
"sprintf-js": "^1.1.2",
"yargs": "^16.2.0"
}
}
40 changes: 23 additions & 17 deletions abap-api-tools/src/ts/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ type AbapConfigType = Record<
>;

type UiConfigTableType = {
header: string;
header?: string;
header_row?: string;
body?: string;
row: string;
footer: string;
footer?: string;
};

type UiConfigType = Record<string, string | UiConfigTableType>;
Expand Down Expand Up @@ -141,7 +141,7 @@ export class Frontend {
"ui",
`${argv.ui}.yaml`
);
this.uiConfig = yamlLoad(this.configPath["ui"]) as UiConfigType;
this.uiConfig = yamlLoad(this.configPath.ui) as UiConfigType;
log.debug(`default ui configuration ${argv.ui}`);
}

Expand Down Expand Up @@ -284,15 +284,11 @@ export class Frontend {
parse(): void {
log.info(
`\nfrontend: ${this.argv.ui || ""} using ${
this.configPath["abapLocal"]
? this.configPath["abap"]
: "default abap.yaml"
this.configPath.abapLocal ? this.configPath.abap : "default abap.yaml"
} ${
this.argv.ui
? "and " +
(this.configPath["uiLocal"]
? this.configPath["ui"]
: "default ui.yaml")
(this.configPath.uiLocal ? this.configPath.ui : "default ui.yaml")
: ""
}\n`
);
Expand Down Expand Up @@ -539,14 +535,22 @@ export class Frontend {
...(this.uiConfig.table as UiConfigTableType),
};

// header
element_template.header = element_template.header
.replace(/~bind/, Param.paramName)
.replace(/~title/, Param.PARAMTEXT);

htmlWriter.write();
htmlWriter.write(element_template.header);
if (Object.keys(element_template).length === 0) {
htmlWriter.write(
`<!-- Table structure not defined in: ${this.configPath.ui} -->`
);
return;
}

// header
if (element_template.header) {
element_template.header = element_template.header
.replace(/~bind/, Param.paramName)
.replace(/~title/, Param.PARAMTEXT);

htmlWriter.write(element_template.header);
}
// header row
if (element_template.header_row) {
for (const [field_name, Field] of Object.entries(_Field)) {
Expand Down Expand Up @@ -592,7 +596,9 @@ export class Frontend {
}

// footer
htmlWriter.write(element_template.footer);
if (element_template.footer) {
htmlWriter.write(element_template.footer);
}
}

structure_init(
Expand Down Expand Up @@ -801,7 +807,7 @@ export class Frontend {

if (!(m.tag in this.uiConfig)) {
throw new Error(
`html element ${m.tag} of ${this.configPath["abap"]} not found in ${this.configPath["ui"]}`
`html element ${m.tag} of ${this.configPath.abap} not found in ${this.configPath.ui}`
);
}

Expand Down

0 comments on commit 112945a

Please sign in to comment.